X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2FCore%2FConfig.php;h=e5515efafc43b75ff600069c1360c57d0af17531;hb=a1c63994d24fa3c1d396fb623c5cb33995ac924f;hp=5703558cf336f93103b53659d3e5598286d7daf7;hpb=82dcc3fe79725689884a39a685770d9fcddd8bed;p=friendica.git diff --git a/include/Core/Config.php b/include/Core/Config.php index 5703558cf3..e5515efafc 100644 --- a/include/Core/Config.php +++ b/include/Core/Config.php @@ -126,37 +126,19 @@ class Config { public static function set($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]); + $a->config[$family][$key] = $value; // manage array value $dbvalue = (is_array($value)?serialize($value):$value); $dbvalue = (is_bool($dbvalue) ? intval($dbvalue) : $dbvalue); - if(is_null(self::get($family,$key,null,true))) { - $a->config[$family][$key] = $value; - $ret = q("INSERT INTO `config` ( `cat`, `k`, `v` ) VALUES ( '%s', '%s', '%s' ) ", - dbesc($family), - dbesc($key), - dbesc($dbvalue) - ); - if($ret) - return $value; - return $ret; - } - $ret = q("UPDATE `config` SET `v` = '%s' WHERE `cat` = '%s' AND `k` = '%s'", - dbesc($dbvalue), + $ret = q("INSERT INTO `config` ( `cat`, `k`, `v` ) VALUES ( '%s', '%s', '%s' ) +ON DUPLICATE KEY UPDATE `v` = '%s'", dbesc($family), - dbesc($key) + dbesc($key), + dbesc($dbvalue), + dbesc($dbvalue) ); - - $a->config[$family][$key] = $value; - if($ret) return $value; return $ret;