Preload Adapter Fix

This commit is contained in:
Philipp Holzer 2019-02-18 14:00:34 +01:00
parent a3152a96c2
commit 2fc81898da
No known key found for this signature in database
GPG key ID: 517BE60E2CE5C8A5
5 changed files with 36 additions and 14 deletions

View file

@ -34,10 +34,13 @@ class JITConfigAdapter extends AbstractDbaConfigAdapter implements IConfigAdapte
$configs = DBA::select('config', ['v', 'k'], ['cat' => $cat]); $configs = DBA::select('config', ['v', 'k'], ['cat' => $cat]);
while ($config = DBA::fetch($configs)) { while ($config = DBA::fetch($configs)) {
$key = $config['k']; $key = $config['k'];
$value = $config['v'];
$return[$key] = $config['v']; if (isset($value) && $value !== '') {
$return[$key] = $value;
$this->in_db[$cat][$key] = true; $this->in_db[$cat][$key] = true;
} }
}
DBA::close($configs); DBA::close($configs);
return [$cat => $config]; return [$cat => $config];

View file

@ -29,11 +29,13 @@ class JITPConfigAdapter extends AbstractDbaConfigAdapter implements IPConfigAdap
if (DBA::isResult($pconfigs)) { if (DBA::isResult($pconfigs)) {
while ($pconfig = DBA::fetch($pconfigs)) { while ($pconfig = DBA::fetch($pconfigs)) {
$key = $pconfig['k']; $key = $pconfig['k'];
$value = $pconfig['v'];
$return[$key] = $pconfig['v']; if (isset($value) && $value !== '') {
$return[$key] = $value;
$this->in_db[$uid][$cat][$key] = true; $this->in_db[$uid][$cat][$key] = true;
} }
}
} else if ($cat != 'config') { } else if ($cat != 'config') {
// Negative caching // Negative caching
$return = "!<unset>!"; $return = "!<unset>!";

View file

@ -32,7 +32,10 @@ class PreloadConfigAdapter extends AbstractDbaConfigAdapter implements IConfigAd
$configs = DBA::select('config', ['cat', 'v', 'k']); $configs = DBA::select('config', ['cat', 'v', 'k']);
while ($config = DBA::fetch($configs)) { while ($config = DBA::fetch($configs)) {
$return[$config['cat']][$config['k']] = $config['v']; $value = $config['v'];
if (isset($value) && $value !== '') {
$return[$config['cat']][$config['k']] = $value;
}
} }
DBA::close($configs); DBA::close($configs);

View file

@ -44,7 +44,10 @@ class PreloadPConfigAdapter extends AbstractDbaConfigAdapter implements IPConfig
$pconfigs = DBA::select('pconfig', ['cat', 'v', 'k'], ['uid' => $uid]); $pconfigs = DBA::select('pconfig', ['cat', 'v', 'k'], ['uid' => $uid]);
while ($pconfig = DBA::fetch($pconfigs)) { while ($pconfig = DBA::fetch($pconfigs)) {
$return[$pconfig['cat']][$pconfig['k']] = $pconfig['v']; $value = $pconfig['v'];
if (isset($value) && $value !== '') {
$return[$pconfig['cat']][$pconfig['k']] = $value;
}
} }
DBA::close($pconfigs); DBA::close($pconfigs);

View file

@ -36,11 +36,12 @@ class ConfigCache implements IConfigCache, IPConfigCache
$keys = array_keys($config[$category]); $keys = array_keys($config[$category]);
foreach ($keys as $key) { foreach ($keys as $key) {
if (isset($config[$category][$key])) { $value = $config[$category][$key];
if (isset($value) && $value !== '!<unset>!') {
if ($overwrite) { if ($overwrite) {
$this->set($category, $key, $config[$category][$key]); $this->set($category, $key, $value);
} else { } else {
$this->setDefault($category, $key, $config[$category][$key]); $this->setDefault($category, $key, $value);
} }
} }
} }
@ -132,12 +133,22 @@ class ConfigCache implements IConfigCache, IPConfigCache
*/ */
public function loadP($uid, array $config) public function loadP($uid, array $config)
{ {
foreach ($config as $category => $values) { $categories = array_keys($config);
foreach ($values as $key => $value) {
foreach ($categories as $category) {
if (isset($config[$category]) && is_array($config[$category])) {
$keys = array_keys($config[$category]);
foreach ($keys as $key) {
$value = $config[$category][$key];
if (isset($value) && $value !== '!<unset>!') {
$this->setP($uid, $category, $key, $value); $this->setP($uid, $category, $key, $value);
} }
} }
} }
}
}
/** /**
* {@inheritdoc} * {@inheritdoc}