From 422be7e212cc52a6776d3b4d01f49e5ff116368a Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 25 Jan 2017 05:33:23 +0000 Subject: [PATCH] Improved handling of non string values in the config --- include/Core/Config.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/include/Core/Config.php b/include/Core/Config.php index 2e92b119a..c495bbd4c 100644 --- a/include/Core/Config.php +++ b/include/Core/Config.php @@ -102,7 +102,7 @@ class Config { ); if (dbm::is_result($ret)) { // manage array value - $val = (preg_match("|^a:[0-9]+:{.*}$|s", $ret[0]['v'])?unserialize( $ret[0]['v']):$ret[0]['v']); + $val = (preg_match("|^a:[0-9]+:{.*}$|s", $ret[0]['v']) ? unserialize($ret[0]['v']) : $ret[0]['v']); // Assign the value from the database to the cache self::$cache[$family][$key] = $val; @@ -139,13 +139,10 @@ class Config { public static function set($family, $key, $value) { $a = get_app(); - // We always store boolean values as integer. - // And when fetching we don't convert them back to boolean. + // We store our setting values in a string variable. // So we have to do the conversion here so that the compare below works. - $dbvalue = (is_bool($value) ? (string)intval($value) : $value); - - // Convert the numeric values to string to make the compare work - $dbvalue = (is_numeric($value) ? (string)$value : $dbvalue); + // The exception are array values. + $dbvalue = (!is_array($value) ? (string)$value : $value); $stored = self::get($family, $key);