X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2FCore%2FConfig.php;h=8e387ca6f0475f06028ce8b9e05b2d6b3dee17db;hb=0adff6f6b893bd7562547bb00021f358383f51ba;hp=bbae746b44dae2f3fffa457aab61988e819fc802;hpb=6c346b1ab64fefebe61be3ddf36cf48eccd52d69;p=friendica.git diff --git a/include/Core/Config.php b/include/Core/Config.php index bbae746b44..8e387ca6f0 100644 --- a/include/Core/Config.php +++ b/include/Core/Config.php @@ -64,11 +64,13 @@ class Config { * The category of the configuration value * @param string $key * The configuration key to query - * @param boolean $refresh - * If true the config is loaded from the db and not from the cache + * @param mixed $default_value optional + * The value to return if key is not set (default: null) + * @param boolean $refresh optional + * If true the config is loaded from the db and not from the cache (default: false) * @return mixed Stored value or null if it does not exist */ - public static function get($family, $key, $refresh = false) { + public static function get($family, $key, $default_value=null, $refresh = false) { global $a; @@ -76,13 +78,13 @@ class Config { // Looking if the whole family isn't set if(isset($a->config[$family])) { if($a->config[$family] === '!!') { - return null; + return $default_value; } } if(isset($a->config[$family][$key])) { if($a->config[$family][$key] === '!!') { - return null; + return $default_value; } return $a->config[$family][$key]; } @@ -137,7 +139,7 @@ class Config { elseif (function_exists("xcache_set")) xcache_set($family."|".$key, '!!', 600);*/ } - return null; + return $default_value; } /** @@ -170,7 +172,7 @@ class Config { // manage array value $dbvalue = (is_array($value)?serialize($value):$value); $dbvalue = (is_bool($dbvalue) ? intval($dbvalue) : $dbvalue); - if(self::get($family,$key,true) === false) { + if(is_null(self::get($family,$key,null,true))) { $a->config[$family][$key] = $value; $ret = q("INSERT INTO `config` ( `cat`, `k`, `v` ) VALUES ( '%s', '%s', '%s' ) ", dbesc($family),