From 91de68d9b377d0322c7609438158da3039334805 Mon Sep 17 00:00:00 2001 From: Peter Rotich <peter@osticket.com> Date: Mon, 11 Jul 2016 19:38:05 +0000 Subject: [PATCH] Lint fixes --- file.php | 2 +- include/class.forms.php | 8 ++++++-- include/class.orm.php | 3 ++- include/class.page.php | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/file.php b/file.php index d62d588eb..ed0a4465e 100644 --- a/file.php +++ b/file.php @@ -51,7 +51,7 @@ if ($file->verifySignature($_GET['signature'], $_GET['expires'])) { // Download the file.. $file->download(@$_GET['disposition'] ?: false, $_GET['expires']); } - catch (Exception $x) { + catch (Exception $ex) { Http::response(500, 'Unable to find that file: '.$ex->getMessage()); } } diff --git a/include/class.forms.php b/include/class.forms.php index 318adbbc1..180057e81 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -1582,15 +1582,19 @@ class ChoiceField extends FormField { $value = JsonDataParser::parse($value) ?: $value; // CDATA table may be built with comma-separated key,value,key,value - if (is_string($value)) { + if (is_string($value) && strpos($value, ',')) { $values = array(); $choices = $this->getChoices(); - foreach (explode(',', $value) as $V) { + $vals = explode(',', $value); + foreach ($vals as $V) { if (isset($choices[$V])) $values[$V] = $choices[$V]; } if (array_filter($values)) $value = $values; + elseif($vals) + list($value) = $vals; + } $config = $this->getConfiguration(); if (!$config['multiselect'] && is_array($value) && count($value) < 2) { diff --git a/include/class.orm.php b/include/class.orm.php index a928f222c..626f78eb1 100644 --- a/include/class.orm.php +++ b/include/class.orm.php @@ -396,9 +396,10 @@ class VerySimpleModel { } function __isset($field) { - return array_key_exists($field, $this->ht) + return ($this->ht && array_key_exists($field, $this->ht)) || isset(static::$meta['joins'][$field]); } + function __unset($field) { if ($this->__isset($field)) unset($this->ht[$field]); diff --git a/include/class.page.php b/include/class.page.php index 920c2ee88..157ad43cd 100644 --- a/include/class.page.php +++ b/include/class.page.php @@ -319,7 +319,7 @@ class Page extends VerySimpleModel { return false; } // New translations (?) - foreach ($vars['trans'] as $lang=>$parts) { + foreach ($vars['trans'] ?: array() as $lang=>$parts) { $content = array('name' => @$parts['title'], 'body' => Format::sanitize(@$parts['body'])); if (!array_filter($content)) continue; -- GitLab