diff options
-rw-r--r-- | Zotlabs/Lib/Config.php | 53 | ||||
-rw-r--r-- | boot.php | 2 |
2 files changed, 19 insertions, 36 deletions
diff --git a/Zotlabs/Lib/Config.php b/Zotlabs/Lib/Config.php index 5e735be34..267543963 100644 --- a/Zotlabs/Lib/Config.php +++ b/Zotlabs/Lib/Config.php @@ -2,7 +2,6 @@ namespace Zotlabs\Lib; -use App; class Config { @@ -15,26 +14,11 @@ class Config { * @param string $family * The category of the configuration value */ - public static function Load($family, $recursionCounter = 0) { - if (! array_key_exists($family, App::$config)) { - App::$config[$family] = []; - } - - // We typically continue when presented with minor DB issues, - // but loading the site configuration is more important. - - // Check for query returning false and give it approx 30 seconds - // to recover if there's a problem. This is intended to fix a - // rare issue on Galera where temporary sync issues were causing - // the site encryption keys to be regenerated, which was causing - // communication issues for members. - - // This code probably belongs at the database layer, but we don't - // necessarily want to shut the site down for problematic queries - // caused by bad data. That could be used in a denial of service - // attack. Those do need to be (and they are) logged. + static public function Load($family) { + if(! array_key_exists($family, \App::$config)) + \App::$config[$family] = array(); - if (! array_key_exists('config_loaded', App::$config[$family])) { + if(! array_key_exists('config_loaded', \App::$config[$family])) { $r = q("SELECT * FROM config WHERE cat = '%s'", dbesc($family)); if ($r === false && !App::$install) { sleep(3); @@ -42,7 +26,7 @@ class Config { if ($recursionCounter > 10) { system_unavailable(); } - self::Load($family, $recursionCounter); + \App::$config[$family]['config_loaded'] = true; } elseif (is_array($r)) { foreach ($r as $rr) { @@ -70,19 +54,19 @@ class Config { * @return mixed * Return the set value, or false if the database update failed */ - public static function Set($family, $key, $value) { + static public function Set($family, $key, $value) { // manage array value $dbvalue = ((is_array($value)) ? 'json:' . json_encode($value) : $value); $dbvalue = ((is_bool($dbvalue)) ? intval($dbvalue) : $dbvalue); - if (self::Get($family, $key) === false || (! self::get_from_storage($family, $key))) { + if(self::Get($family, $key) === false || (! self::get_from_storage($family, $key))) { $ret = q("INSERT INTO config ( cat, k, v ) VALUES ( '%s', '%s', '%s' ) ", dbesc($family), dbesc($key), dbesc($dbvalue) ); - if ($ret) { - App::$config[$family][$key] = $value; + if($ret) { + \App::$config[$family][$key] = $value; $ret = $value; } return $ret; @@ -94,8 +78,8 @@ class Config { dbesc($key) ); - if ($ret) { - App::$config[$family][$key] = $value; + if($ret) { + \App::$config[$family][$key] = $value; $ret = $value; } @@ -124,10 +108,9 @@ class Config { if ((! array_key_exists($family, App::$config)) || (! array_key_exists('config_loaded', App::$config[$family]))) { self::Load($family); - } - if (array_key_exists('config_loaded', App::$config[$family])) { - if (! array_key_exists($key, App::$config[$family])) { + if(array_key_exists('config_loaded', \App::$config[$family])) { + if(! array_key_exists($key, \App::$config[$family])) { return $default; } @@ -162,13 +145,12 @@ class Config { * The configuration key to delete * @return mixed */ - public static function Delete($family, $key) { + static public function Delete($family, $key) { $ret = false; - if (array_key_exists($family, App::$config) && array_key_exists($key, App::$config[$family])) { - unset(App::$config[$family][$key]); - } + if(array_key_exists($family, \App::$config) && array_key_exists($key, \App::$config[$family])) + unset(\App::$config[$family][$key]); $ret = q("DELETE FROM config WHERE cat = '%s' AND k = '%s'", dbesc($family), @@ -191,7 +173,7 @@ class Config { * The configuration key to query * @return mixed */ - private static function get_from_storage($family, $key) { + static private function get_from_storage($family,$key) { $ret = q("SELECT * FROM config WHERE cat = '%s' AND k = '%s' LIMIT 1", dbesc($family), dbesc($key) @@ -199,4 +181,5 @@ class Config { return $ret; } + } @@ -62,7 +62,7 @@ require_once('include/conversation.php'); require_once('include/acl_selectors.php'); define('PLATFORM_NAME', 'hubzilla'); -define('STD_VERSION', '8.9'); +define('STD_VERSION', '8.8.3'); define('ZOT_REVISION', '6.0'); define('DB_UPDATE_VERSION', 1259); |