X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FCore%2FConfig%2FJITConfigAdapter.php;h=b985d91c2122ade49efee07753ecfccaa9c1911a;hb=8dc5b04be7cd9cb2eb77ed9824815efe27369bee;hp=0e7731690bf4dcca109e08aaca7208ed5846bf53;hpb=88353ce56f0e5da6352af2d999a58bd0c9b375f7;p=friendica.git diff --git a/src/Core/Config/JITConfigAdapter.php b/src/Core/Config/JITConfigAdapter.php index 0e7731690b..b985d91c21 100644 --- a/src/Core/Config/JITConfigAdapter.php +++ b/src/Core/Config/JITConfigAdapter.php @@ -1,9 +1,8 @@ + * @author Hypolite Petovan */ class JITConfigAdapter extends BaseObject implements IConfigAdapter { @@ -27,8 +26,8 @@ class JITConfigAdapter extends BaseObject implements IConfigAdapter return; } - $configs = dba::select('config', ['v', 'k'], ['cat' => $cat]); - while ($config = dba::fetch($configs)) { + $configs = DBA::select('config', ['v', 'k'], ['cat' => $cat]); + while ($config = DBA::fetch($configs)) { $k = $config['k']; self::getApp()->setConfigValue($cat, $k, $config['v']); @@ -38,7 +37,7 @@ class JITConfigAdapter extends BaseObject implements IConfigAdapter $this->in_db[$cat][$k] = true; } } - dba::close($configs); + DBA::close($configs); } public function get($cat, $k, $default_value = null, $refresh = false) @@ -56,8 +55,8 @@ class JITConfigAdapter extends BaseObject implements IConfigAdapter } } - $config = dba::selectFirst('config', ['v'], ['cat' => $cat, 'k' => $k]); - if (DBM::is_result($config)) { + $config = DBA::selectFirst('config', ['v'], ['cat' => $cat, 'k' => $k]); + if (DBA::isResult($config)) { // manage array value $value = (preg_match("|^a:[0-9]+:{.*}$|s", $config['v']) ? unserialize($config['v']) : $config['v']); @@ -66,11 +65,17 @@ class JITConfigAdapter extends BaseObject implements IConfigAdapter $this->in_db[$cat][$k] = true; return $value; } elseif (isset($a->config[$cat][$k])) { - // Assign the value (mostly) from the .htconfig.php to the cache + // Assign the value (mostly) from config/local.ini.php file to the cache $this->cache[$cat][$k] = $a->config[$cat][$k]; $this->in_db[$cat][$k] = false; return $a->config[$cat][$k]; + } elseif (isset($a->config[$k])) { + // Assign the value (mostly) from config/local.ini.php file to the cache + $this->cache[$k] = $a->config[$k]; + $this->in_db[$k] = false; + + return $a->config[$k]; } $this->cache[$cat][$k] = '!!'; @@ -90,6 +95,13 @@ class JITConfigAdapter extends BaseObject implements IConfigAdapter $stored = $this->get($cat, $k, null, true); + if (!isset($this->in_db[$cat])) { + $this->in_db[$cat] = []; + } + if (!isset($this->in_db[$cat][$k])) { + $this->in_db[$cat] = false; + } + if (($stored === $dbvalue) && $this->in_db[$cat][$k]) { return true; } @@ -102,11 +114,10 @@ class JITConfigAdapter extends BaseObject implements IConfigAdapter // manage array value $dbvalue = (is_array($value) ? serialize($value) : $dbvalue); - $result = dba::update('config', ['v' => $dbvalue], ['cat' => $cat, 'k' => $k], true); + $result = DBA::update('config', ['v' => $dbvalue], ['cat' => $cat, 'k' => $k], true); if ($result) { $this->in_db[$cat][$k] = true; - return $value; } return $result; @@ -119,7 +130,7 @@ class JITConfigAdapter extends BaseObject implements IConfigAdapter unset($this->in_db[$cat][$k]); } - $result = dba::delete('config', ['cat' => $cat, 'k' => $k]); + $result = DBA::delete('config', ['cat' => $cat, 'k' => $k]); return $result; }