]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/PConfig.php
Using getopt for CLI arguments (#5446)
[friendica.git] / src / Core / PConfig.php
index bfa52f5a36ebd7e480d97d2c638ccf8a77b2958e..e8b5c6ca5af2be985e99b2be1a63960015d07fcc 100644 (file)
@@ -9,7 +9,6 @@
 namespace Friendica\Core;
 
 use Friendica\BaseObject;
-use Friendica\Core\Config;
 
 require_once 'include/dba.php';
 
@@ -29,9 +28,12 @@ class PConfig extends BaseObject
 
        public static function init($uid)
        {
-               $a = self::getApp();
+               // Database isn't ready or populated yet
+               if (!(self::getApp()->mode & \Friendica\App::MODE_DBCONFIGAVAILABLE)) {
+                       return;
+               }
 
-               if (isset($a->config['system']['config_adapter']) && $a->config['system']['config_adapter'] == 'preload') {
+               if (self::getApp()->getConfigValue('system', 'config_adapter') == 'preload') {
                        self::$adapter = new Config\PreloadPConfigAdapter($uid);
                } else {
                        self::$adapter = new Config\JITPConfigAdapter($uid);
@@ -51,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);
                }
@@ -75,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);
                }
@@ -95,10 +107,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()->mode & \Friendica\App::MODE_DBCONFIGAVAILABLE)) {
+                       return false;
+               }
+
                if (empty(self::$adapter)) {
                        self::init($uid);
                }
@@ -120,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);
                }