]> git.mxchange.org Git - friendica.git/blobdiff - include/Core/Config.php
Disable richtext editor for frio - followup for #2938
[friendica.git] / include / Core / Config.php
index de371eb7f34592654034b70f4dac14984058477d..a5eca0570a56efc86f1ecf26ed4dae91f71e07df 100644 (file)
@@ -100,8 +100,7 @@ class Config {
                        $a->config[$family][$key] = $val;
 
                        return $val;
-               }
-               else {
+               } else {
                        $a->config[$family][$key] = '!<unset>!';
                }
                return $default_value;
@@ -126,35 +125,35 @@ class Config {
        public static function set($family, $key, $value) {
                global $a;
 
+               $stored = self::get($family, $key);
+
+               if ($stored == $value) {
+                       return true;
+               }
+
                $a->config[$family][$key] = $value;
 
                // manage array value
-               $dbvalue = (is_array($value) ? serialize($value):$value);
+               $dbvalue = (is_array($value) ? serialize($value) : $value);
                $dbvalue = (is_bool($dbvalue) ? intval($dbvalue) : $dbvalue);
 
-               // The "INSERT" command is very cost intense. It saves performance to do it this way.
-               $ret = q("SELECT `v` FROM `config` WHERE `cat` = '%s' AND `k` = '%s' ORDER BY `id` DESC LIMIT 1",
-                       dbesc($family),
-                       dbesc($key)
-               );
-
-               if (!$ret) {
+               if (is_null($stored)) {
                        $ret = q("INSERT INTO `config` (`cat`, `k`, `v`) VALUES ('%s', '%s', '%s') ON DUPLICATE KEY UPDATE `v` = '%s'",
                                dbesc($family),
                                dbesc($key),
                                dbesc($dbvalue),
                                dbesc($dbvalue)
                        );
-               } elseif ($ret[0]['v'] != $dbvalue) {
+               } else {
                        $ret = q("UPDATE `config` SET `v` = '%s' WHERE `cat` = '%s' AND `k` = '%s'",
                                dbesc($dbvalue),
                                dbesc($family),
                                dbesc($key)
                        );
                }
-               if ($ret)
+               if ($ret) {
                        return $value;
-
+               }
                return $ret;
        }
 
@@ -173,8 +172,9 @@ class Config {
        public static function delete($family, $key) {
 
                global $a;
-               if (x($a->config[$family],$key))
+               if (x($a->config[$family],$key)) {
                        unset($a->config[$family][$key]);
+               }
                $ret = q("DELETE FROM `config` WHERE `cat` = '%s' AND `k` = '%s'",
                        dbesc($family),
                        dbesc($key)