]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/PConfig.php
Rework App modes
[friendica.git] / src / Core / PConfig.php
index 274122deda4513dd63acaeded4414989b0d7fd21..aa5f75abe737b2350e199ae9083e899e6a6bce0e 100644 (file)
@@ -9,7 +9,6 @@
 namespace Friendica\Core;
 
 use Friendica\BaseObject;
-use Friendica\Core\Config;
 
 require_once 'include/dba.php';
 
@@ -29,7 +28,12 @@ class PConfig extends BaseObject
 
        public static function init($uid)
        {
-               if (Config::get('system', 'config_adapter') == 'preload') {
+               // Database isn't ready or populated yet
+               if (!(self::getApp()->mode & \Friendica\App::MODE_DBCONFIGAVAILABLE)) {
+                       return;
+               }
+
+               if (self::getApp()->getConfigValue('system', 'config_adapter') == 'preload') {
                        self::$adapter = new Config\PreloadPConfigAdapter($uid);
                } else {
                        self::$adapter = new Config\JITPConfigAdapter($uid);
@@ -49,6 +53,11 @@ class PConfig extends BaseObject
         */
        public static function load($uid, $family)
        {
+               // Database isn't ready or populated yet
+               if (!(self::getApp()->mode & \Friendica\App::MODE_DBCONFIGAVAILABLE)) {
+                       return;
+               }
+
                if (empty(self::$adapter)) {
                        self::init($uid);
                }
@@ -73,6 +82,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()->mode & \Friendica\App::MODE_DBCONFIGAVAILABLE)) {
+                       return;
+               }
+
                if (empty(self::$adapter)) {
                        self::init($uid);
                }
@@ -97,6 +111,11 @@ class PConfig extends BaseObject
         */
        public static function set($uid, $family, $key, $value)
        {
+               // Database isn't ready or populated yet
+               if (!(self::getApp()->mode & \Friendica\App::MODE_DBCONFIGAVAILABLE)) {
+                       return false;
+               }
+
                if (empty(self::$adapter)) {
                        self::init($uid);
                }
@@ -118,6 +137,11 @@ class PConfig extends BaseObject
         */
        public static function delete($uid, $family, $key)
        {
+               // Database isn't ready or populated yet
+               if (!(self::getApp()->mode & \Friendica\App::MODE_DBCONFIGAVAILABLE)) {
+                       return false;
+               }
+
                if (empty(self::$adapter)) {
                        self::init($uid);
                }