]> git.mxchange.org Git - friendica.git/blobdiff - include/Core/Config.php
Merge pull request #2851 from annando/1610-performance-nodeinfo
[friendica.git] / include / Core / Config.php
index 5703558cf336f93103b53659d3e5598286d7daf7..e5515efafc43b75ff600069c1360c57d0af17531 100644 (file)
@@ -126,37 +126,19 @@ class Config {
        public static function set($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]);
+               $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;