X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FCore%2FConfig.php;h=f71522d068b9c63e6dbc4a7cd158fcf4d0a7df29;hb=761bdafa34bfdf1b2b43a3f06ae092e0925898ac;hp=3c1d3245fd2256e3bde8fdd3801d4181ce84e8de;hpb=7acb4b04343df31c2cc78214fae5429c66d95fb2;p=friendica.git diff --git a/src/Core/Config.php b/src/Core/Config.php index 3c1d3245fd..f71522d068 100644 --- a/src/Core/Config.php +++ b/src/Core/Config.php @@ -8,6 +8,7 @@ */ namespace Friendica\Core; +use Friendica\App; use Friendica\BaseObject; use Friendica\Core\Config; @@ -29,6 +30,11 @@ class Config extends BaseObject public static function init() { + // Database isn't ready or populated yet + if (!(self::getApp()->mode & App::MODE_DBCONFIGAVAILABLE)) { + return; + } + if (self::getApp()->getConfigValue('system', 'config_adapter') == 'preload') { self::$adapter = new Config\PreloadConfigAdapter(); } else { @@ -48,6 +54,11 @@ class Config extends BaseObject */ public static function load($family = "config") { + // Database isn't ready or populated yet + if (!(self::getApp()->mode & App::MODE_DBCONFIGAVAILABLE)) { + return; + } + if (empty(self::$adapter)) { self::init(); } @@ -76,6 +87,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()->mode & App::MODE_DBCONFIGAVAILABLE)) { + return self::getApp()->getConfigValue($family, $key, $default_value); + } + if (empty(self::$adapter)) { self::init(); } @@ -95,10 +111,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()->mode & App::MODE_DBCONFIGAVAILABLE)) { + return false; + } + if (empty(self::$adapter)) { self::init(); } @@ -119,6 +140,11 @@ class Config extends BaseObject */ public static function delete($family, $key) { + // Database isn't ready or populated yet + if (!(self::getApp()->mode & App::MODE_DBCONFIGAVAILABLE)) { + return false; + } + if (empty(self::$adapter)) { self::init(); }