]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/Config.php
Rework Profile::getThemeUid to ignore query parameter and include $a->profile_uid
[friendica.git] / src / Core / Config.php
index 3c1d3245fd2256e3bde8fdd3801d4181ce84e8de..f191c10a0e3cab93a6be7d0eb0c4afec16719ce7 100644 (file)
@@ -8,11 +8,10 @@
  */
 namespace Friendica\Core;
 
+use Friendica\App;
 use Friendica\BaseObject;
 use Friendica\Core\Config;
 
-require_once 'include/dba.php';
-
 /**
  * @brief Arbitrary system configuration storage
  *
@@ -29,6 +28,11 @@ class Config extends BaseObject
 
        public static function init()
        {
+               // Database isn't ready or populated yet
+               if (!self::getApp()->getMode()->has(App\Mode::DBCONFIGAVAILABLE)) {
+                       return;
+               }
+
                if (self::getApp()->getConfigValue('system', 'config_adapter') == 'preload') {
                        self::$adapter = new Config\PreloadConfigAdapter();
                } else {
@@ -48,6 +52,11 @@ class Config extends BaseObject
         */
        public static function load($family = "config")
        {
+               // Database isn't ready or populated yet
+               if (!self::getApp()->getMode()->has(App\Mode::DBCONFIGAVAILABLE)) {
+                       return;
+               }
+
                if (empty(self::$adapter)) {
                        self::init();
                }
@@ -76,6 +85,11 @@ class Config extends BaseObject
         */
        public static function get($family, $key, $default_value = null, $refresh = false)
        {
+               // Database isn't ready or populated yet, fallback to file config
+               if (!self::getApp()->getMode()->has(App\Mode::DBCONFIGAVAILABLE)) {
+                       return self::getApp()->getConfigValue($family, $key, $default_value);
+               }
+
                if (empty(self::$adapter)) {
                        self::init();
                }
@@ -95,10 +109,15 @@ class Config extends BaseObject
         * @param string $key    The configuration key to set
         * @param mixed  $value  The value to store
         *
-        * @return mixed Stored $value or false if the database update failed
+        * @return bool Operation success
         */
        public static function set($family, $key, $value)
        {
+               // Database isn't ready or populated yet
+               if (!self::getApp()->getMode()->has(App\Mode::DBCONFIGAVAILABLE)) {
+                       return false;
+               }
+
                if (empty(self::$adapter)) {
                        self::init();
                }
@@ -119,6 +138,11 @@ class Config extends BaseObject
         */
        public static function delete($family, $key)
        {
+               // Database isn't ready or populated yet
+               if (!self::getApp()->getMode()->has(App\Mode::DBCONFIGAVAILABLE)) {
+                       return false;
+               }
+
                if (empty(self::$adapter)) {
                        self::init();
                }