X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FCore%2FConfig%2FJITPConfigAdapter.php;h=b1a15601cc4cdaa28efbd7687c7c0aeb65e65097;hb=a0b14a46cb83b93ea5f42437bc78aafd20eec70c;hp=223cc542dcdb01e58d80e311d7d033dbef943994;hpb=4af0119b7310e9731e60b11a14fd917580b95715;p=friendica.git diff --git a/src/Core/Config/JITPConfigAdapter.php b/src/Core/Config/JITPConfigAdapter.php index 223cc542dc..b1a15601cc 100644 --- a/src/Core/Config/JITPConfigAdapter.php +++ b/src/Core/Config/JITPConfigAdapter.php @@ -18,16 +18,19 @@ class JITPConfigAdapter implements IPConfigAdapter * The config cache of this adapter * @var IPConfigCache */ - private $config; + private $configCache; /** - * @param IPConfigCache $config The config cache of this adapter + * @param IPConfigCache $configCache The config cache of this adapter */ - public function __construct($config) + public function __construct(IPConfigCache $configCache) { - $this->config = $config; + $this->configCache = $configCache; } + /** + * {@inheritdoc} + */ public function load($uid, $cat) { $pconfigs = DBA::select('pconfig', ['v', 'k'], ['cat' => $cat, 'uid' => $uid]); @@ -35,32 +38,35 @@ class JITPConfigAdapter implements IPConfigAdapter while ($pconfig = DBA::fetch($pconfigs)) { $k = $pconfig['k']; - $this->config->setP($uid, $cat, $k, $pconfig['v']); + $this->configCache->setP($uid, $cat, $k, $pconfig['v']); $this->in_db[$uid][$cat][$k] = true; } } else if ($cat != 'config') { // Negative caching - $this->config->setP($uid, $cat, null, "!!"); + $this->configCache->setP($uid, $cat, null, "!!"); } DBA::close($pconfigs); } + /** + * {@inheritdoc} + */ public function get($uid, $cat, $k, $default_value = null, $refresh = false) { if (!$refresh) { // Looking if the whole family isn't set - if ($this->config->getP($uid, $cat) !== null) { - if ($this->config->getP($uid, $cat) === '!!') { + if ($this->configCache->getP($uid, $cat) !== null) { + if ($this->configCache->getP($uid, $cat) === '!!') { return $default_value; } } - if ($this->config->getP($uid, $cat, $k) !== null) { - if ($this->config->getP($uid, $cat, $k) === '!!') { + if ($this->configCache->getP($uid, $cat, $k) !== null) { + if ($this->configCache->getP($uid, $cat, $k) === '!!') { return $default_value; } - return $this->config->getP($uid, $cat, $k); + return $this->configCache->getP($uid, $cat, $k); } } @@ -68,13 +74,13 @@ class JITPConfigAdapter implements IPConfigAdapter if (DBA::isResult($pconfig)) { $val = (preg_match("|^a:[0-9]+:{.*}$|s", $pconfig['v']) ? unserialize($pconfig['v']) : $pconfig['v']); - $this->config->setP($uid, $cat, $k, $val); + $this->configCache->setP($uid, $cat, $k, $val); $this->in_db[$uid][$cat][$k] = true; return $val; } else { - $this->config->setP($uid, $cat, $k, '!!'); + $this->configCache->setP($uid, $cat, $k, '!!'); $this->in_db[$uid][$cat][$k] = false; @@ -82,6 +88,9 @@ class JITPConfigAdapter implements IPConfigAdapter } } + /** + * {@inheritdoc} + */ public function set($uid, $cat, $k, $value) { // We store our setting values in a string variable. @@ -95,7 +104,7 @@ class JITPConfigAdapter implements IPConfigAdapter return true; } - $this->config->setP($uid, $cat, $k, $value); + $this->configCache->setP($uid, $cat, $k, $value); // manage array value $dbvalue = (is_array($value) ? serialize($value) : $dbvalue); @@ -109,9 +118,12 @@ class JITPConfigAdapter implements IPConfigAdapter return $result; } + /** + * {@inheritdoc} + */ public function delete($uid, $cat, $k) { - $this->config->deleteP($uid, $cat, $k); + $this->configCache->deleteP($uid, $cat, $k); if (!empty($this->in_db[$uid][$cat][$k])) { unset($this->in_db[$uid][$cat][$k]);