X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fconfig.php;h=d138d20534907fc953e917a6d0d43d968ceeb60c;hb=74954e6c68fce7cca5c1fcb5589c7c25a815f474;hp=60cd00cf6466bf606787a433ac4214e86b2af0f5;hpb=cc7d849ce393a57fe6bb347c48c9a02f7e483789;p=friendica.git diff --git a/include/config.php b/include/config.php index 60cd00cf64..d138d20534 100644 --- a/include/config.php +++ b/include/config.php @@ -22,13 +22,13 @@ function load_config($family) { if(count($r)) { foreach($r as $rr) { $k = $rr['k']; - if ($rr['cat'] === 'config') { + if ($family === 'config') { $a->config[$k] = $rr['v']; } else { $a->config[$family][$k] = $rr['v']; } } - } else if (isset($rr) && ($rr['cat'] != 'config')) { + } else if ($family != 'config') { // Negative caching $a->config[$family] = "!!"; } @@ -68,7 +68,7 @@ function get_config($family, $key, $instore = false) { ); if(count($ret)) { // manage array value - $val = (preg_match("|^a:[0-9]+:{.*}$|", $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']); $a->config[$family][$key] = $val; return $val; } @@ -85,6 +85,15 @@ function get_config($family, $key, $instore = false) { if(! function_exists('set_config')) { function set_config($family,$key,$value) { global $a; + + // If $a->config[$family] has been previously set to '!!', then + // $a->config[$family][$key] will evaluate to $a->config[$family][0], and + // $a->config[$family][$key] = $value will be equivalent to + // $a->config[$family][0] = $value[0] (this causes infuriating bugs), + // so unset the family before assigning a value to a family's key + if($a->config[$family] === '!!') + unset($a->config[$family]); + // manage array value $dbvalue = (is_array($value)?serialize($value):$value); $dbvalue = (is_bool($dbvalue) ? intval($dbvalue) : $dbvalue); @@ -126,7 +135,7 @@ function load_pconfig($uid,$family) { $k = $rr['k']; $a->config[$uid][$family][$k] = $rr['v']; } - } else if ($rr['cat'] != 'config') { + } else if ($family != 'config') { // Negative caching $a->config[$uid][$family] = "!!"; } @@ -162,7 +171,7 @@ function get_pconfig($uid,$family, $key, $instore = false) { ); if(count($ret)) { - $val = (preg_match("|^a:[0-9]+:{.*}$|", $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']); $a->config[$uid][$family][$key] = $val; return $val; }