]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/PConfig.php
AutoInstall Test fix
[friendica.git] / src / Core / PConfig.php
index 274122deda4513dd63acaeded4414989b0d7fd21..2080f716ceb5cfac2b329108cd004535210ecfa3 100644 (file)
@@ -8,8 +8,8 @@
  */
 namespace Friendica\Core;
 
+use Friendica\App;
 use Friendica\BaseObject;
-use Friendica\Core\Config;
 
 require_once 'include/dba.php';
 
@@ -29,7 +29,14 @@ class PConfig extends BaseObject
 
        public static function init($uid)
        {
-               if (Config::get('system', 'config_adapter') == 'preload') {
+               $a = self::getApp();
+
+               // Database isn't ready or populated yet
+               if (!$a->getMode()->has(App\Mode::DBCONFIGAVAILABLE)) {
+                       return;
+               }
+
+               if ($a->getConfigValue('system', 'config_adapter') == 'preload') {
                        self::$adapter = new Config\PreloadPConfigAdapter($uid);
                } else {
                        self::$adapter = new Config\JITPConfigAdapter($uid);
@@ -49,6 +56,11 @@ class PConfig extends BaseObject
         */
        public static function load($uid, $family)
        {
+               // Database isn't ready or populated yet
+               if (!self::getApp()->getMode()->has(App\Mode::DBCONFIGAVAILABLE)) {
+                       return;
+               }
+
                if (empty(self::$adapter)) {
                        self::init($uid);
                }
@@ -73,6 +85,11 @@ class PConfig extends BaseObject
         */
        public static function get($uid, $family, $key, $default_value = null, $refresh = false)
        {
+               // Database isn't ready or populated yet
+               if (!self::getApp()->getMode()->has(App\Mode::DBCONFIGAVAILABLE)) {
+                       return;
+               }
+
                if (empty(self::$adapter)) {
                        self::init($uid);
                }
@@ -93,10 +110,15 @@ class PConfig extends BaseObject
         * @param string $key    The configuration key to set
         * @param string $value  The value to store
         *
-        * @return mixed Stored $value or false
+        * @return bool Operation success
         */
        public static function set($uid, $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($uid);
                }
@@ -118,6 +140,11 @@ class PConfig extends BaseObject
         */
        public static function delete($uid, $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($uid);
                }