set config_loaded with uid

This commit is contained in:
Philipp Holzer 2019-02-18 14:34:30 +01:00
parent f825fa1d1c
commit 1194e9b41e
No known key found for this signature in database
GPG Key ID: 517BE60E2CE5C8A5

View File

@ -13,7 +13,10 @@ use Friendica\Database\DBA;
*/
class PreloadPConfigAdapter extends AbstractDbaConfigAdapter implements IPConfigAdapter
{
private $config_loaded = false;
/**
* @var array true if config for user is loaded
*/
private $config_loaded;
/**
* @param int $uid The UID of the current user
@ -25,6 +28,8 @@ class PreloadPConfigAdapter extends AbstractDbaConfigAdapter implements IPConfig
if (isset($uid)) {
$this->load($uid, 'config');
}
$this->config_loaded = [];
}
/**
@ -34,11 +39,11 @@ class PreloadPConfigAdapter extends AbstractDbaConfigAdapter implements IPConfig
{
$return = [];
if ($this->config_loaded) {
if (empty($uid)) {
return $return;
}
if (empty($uid)) {
if ($this->isLoaded($uid, $cat, null)) {
return $return;
}
@ -53,7 +58,7 @@ class PreloadPConfigAdapter extends AbstractDbaConfigAdapter implements IPConfig
}
DBA::close($pconfigs);
$this->config_loaded = true;
$this->config_loaded[$uid] = true;
return $return;
}
@ -67,7 +72,7 @@ class PreloadPConfigAdapter extends AbstractDbaConfigAdapter implements IPConfig
return '!<unset>!';
}
if (!$this->config_loaded) {
if (!$this->isLoaded($uid, $cat, $key)) {
$this->load($uid, $cat);
}
@ -92,7 +97,7 @@ class PreloadPConfigAdapter extends AbstractDbaConfigAdapter implements IPConfig
return false;
}
if (!$this->config_loaded) {
if ($this->isLoaded($uid, $cat, $key)) {
$this->load($uid, $cat);
}
// We store our setting values as strings.
@ -121,7 +126,7 @@ class PreloadPConfigAdapter extends AbstractDbaConfigAdapter implements IPConfig
return false;
}
if (!$this->config_loaded) {
if (!$this->isLoaded($uid, $cat, $key)) {
$this->load($uid, $cat);
}
@ -139,6 +144,6 @@ class PreloadPConfigAdapter extends AbstractDbaConfigAdapter implements IPConfig
return false;
}
return $this->config_loaded;
return isset($this->config_loaded[$uid]) && $this->config_loaded[$uid];
}
}