mirror of
https://github.com/friendica/friendica
synced 2024-12-23 13:20:21 +00:00
Improved handling of non string values in the config
This commit is contained in:
parent
becfeaf0b7
commit
422be7e212
1 changed files with 4 additions and 7 deletions
|
@ -102,7 +102,7 @@ class Config {
|
||||||
);
|
);
|
||||||
if (dbm::is_result($ret)) {
|
if (dbm::is_result($ret)) {
|
||||||
// manage array value
|
// 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
|
// Assign the value from the database to the cache
|
||||||
self::$cache[$family][$key] = $val;
|
self::$cache[$family][$key] = $val;
|
||||||
|
@ -139,13 +139,10 @@ class Config {
|
||||||
public static function set($family, $key, $value) {
|
public static function set($family, $key, $value) {
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
|
||||||
// We always store boolean values as integer.
|
// We store our setting values in a string variable.
|
||||||
// And when fetching we don't convert them back to boolean.
|
|
||||||
// So we have to do the conversion here so that the compare below works.
|
// So we have to do the conversion here so that the compare below works.
|
||||||
$dbvalue = (is_bool($value) ? (string)intval($value) : $value);
|
// The exception are array values.
|
||||||
|
$dbvalue = (!is_array($value) ? (string)$value : $value);
|
||||||
// Convert the numeric values to string to make the compare work
|
|
||||||
$dbvalue = (is_numeric($value) ? (string)$value : $dbvalue);
|
|
||||||
|
|
||||||
$stored = self::get($family, $key);
|
$stored = self::get($family, $key);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue