From: stevetruckstuff Date: Fri, 18 Aug 2006 21:26:04 +0000 (+0000) Subject: Resolve confusing var names for preferences. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=f2e129237014bc6a796cee2085aaeb62b778d04b;p=squirrelmail.git Resolve confusing var names for preferences. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@11613 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/functions/options.php b/functions/options.php index 747d85e4..a8236919 100644 --- a/functions/options.php +++ b/functions/options.php @@ -175,8 +175,20 @@ class SquirrelOption { $this->script = ''; $this->post_script = ''; - /* Check for a current value. */ - if (isset($GLOBALS[$name])) { + /** + * Check for a current value. If the $GLOBALS[] value exists, we also + * need to make sure it is the same data type as the initial value to + * make sure we are looking at the correct preference. + */ + $var_type = NULL; + if (!empty($initial_value)) { + $var_type = gettype($initial_value); + } elseif (is_array($possible_values)) { + list($index, $x) = each ($possible_values); + $var_type = gettype($index); + } + + if (isset($GLOBALS[$name]) && (is_null($var_type) ? true : $var_type == gettype($GLOBALS[$name]))) { $this->value = $GLOBALS[$name]; } else if (!empty($initial_value)) { $this->value = $initial_value;