]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/Config.php
Fewer Defaults
[friendica.git] / src / Core / Config.php
index d3daece159e1863c94357692409e1fef76bb5a65..5e162a3fa4e36536c9dbb562071b669099d7396a 100644 (file)
@@ -11,6 +11,8 @@ namespace Friendica\Core;
 use Friendica\Database\DBM;
 use dba;
 
+require_once 'include/dba.php';
+
 /**
  * @brief Arbitrary sytem configuration storage
  *
@@ -47,7 +49,7 @@ class Config
 
                $a = get_app();
 
-               $r = dba::select('config', array('v', 'k'), array('cat' => $family));
+               $r = dba::select('config', ['v', 'k'], ['cat' => $family]);
                while ($rr = dba::fetch($r)) {
                        $k = $rr['k'];
                        if ($family === 'config') {
@@ -95,10 +97,10 @@ class Config
                        }
                }
 
-               $ret = dba::select('config', array('v'), array('cat' => $family, 'k' => $key), array('limit' => 1));
-               if (DBM::is_result($ret)) {
+               $config = dba::selectFirst('config', ['v'], ['cat' => $family, 'k' => $key]);
+               if (DBM::is_result($config)) {
                        // manage array value
-                       $val = (preg_match("|^a:[0-9]+:{.*}$|s", $ret['v']) ? unserialize($ret['v']) : $ret['v']);
+                       $val = (preg_match("|^a:[0-9]+:{.*}$|s", $config['v']) ? unserialize($config['v']) : $config['v']);
 
                        // Assign the value from the database to the cache
                        self::$cache[$family][$key] = $val;
@@ -128,7 +130,7 @@ class Config
         *
         * @param string $family The category of the configuration value
         * @param string $key    The configuration key to set
-        * @param string $value  The value to store
+        * @param mixed  $value  The value to store
         *
         * @return mixed Stored $value or false if the database update failed
         */
@@ -159,7 +161,7 @@ class Config
                // manage array value
                $dbvalue = (is_array($value) ? serialize($value) : $dbvalue);
 
-               $ret = dba::update('config', array('v' => $dbvalue), array('cat' => $family, 'k' => $key), true);
+               $ret = dba::update('config', ['v' => $dbvalue], ['cat' => $family, 'k' => $key], true);
 
                if ($ret) {
                        self::$in_db[$family][$key] = true;
@@ -186,7 +188,7 @@ class Config
                        unset(self::$in_db[$family][$key]);
                }
 
-               $ret = dba::delete('config', array('cat' => $family, 'k' => $key));
+               $ret = dba::delete('config', ['cat' => $family, 'k' => $key]);
 
                return $ret;
        }