]> git.mxchange.org Git - friendica.git/blobdiff - include/config.php
Merge pull request #656 from fabrixxm/master
[friendica.git] / include / config.php
index 1f2a70e5a144bc4529523bd104b1428646b1c29b..d138d20534907fc953e917a6d0d43d968ceeb60c 100644 (file)
@@ -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 '!<unset>!', 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>!')
+               unset($a->config[$family]);
+
        // manage array value
        $dbvalue = (is_array($value)?serialize($value):$value);
        $dbvalue = (is_bool($dbvalue) ? intval($dbvalue) : $dbvalue);
@@ -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;
        }