mirror of
https://github.com/friendica/friendica
synced 2025-04-26 10:30:11 +00:00
Assure that deleted cat/keys are working as expected
- A deleted cache-key would delete a merged cache-key as well - Deleting a key in the Model results in reloading the config to assure any value from underlying files
This commit is contained in:
parent
fd882abd80
commit
11a8bd17e3
5 changed files with 65 additions and 42 deletions
|
@ -71,6 +71,8 @@ class Config implements IManageConfigValues
|
|||
{
|
||||
try {
|
||||
$this->configFileManager->saveData($this->configCache);
|
||||
// reload after the save to possible reload default values of lower source-priorities again
|
||||
$this->reload();
|
||||
} catch (ConfigFileException $e) {
|
||||
throw new ConfigPersistenceException('Cannot save config', $e);
|
||||
}
|
||||
|
@ -116,7 +118,7 @@ class Config implements IManageConfigValues
|
|||
/** {@inheritDoc} */
|
||||
public function delete(string $cat, string $key): bool
|
||||
{
|
||||
if ($this->configCache->delete($cat, $key, Cache::SOURCE_DATA)) {
|
||||
if ($this->configCache->delete($cat, $key)) {
|
||||
$this->save();
|
||||
return true;
|
||||
} else {
|
||||
|
|
|
@ -55,6 +55,11 @@ class Cache
|
|||
*/
|
||||
private $source = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $delConfig = [];
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
|
@ -232,6 +237,7 @@ class Cache
|
|||
if (isset($this->config[$cat][$key])) {
|
||||
unset($this->config[$cat][$key]);
|
||||
unset($this->source[$cat][$key]);
|
||||
$this->delConfig[$cat][$key] = true;
|
||||
if (count($this->config[$cat]) == 0) {
|
||||
unset($this->config[$cat]);
|
||||
unset($this->source[$cat]);
|
||||
|
@ -313,6 +319,19 @@ class Cache
|
|||
}
|
||||
}
|
||||
|
||||
$delCategories = array_keys($cache->delConfig);
|
||||
|
||||
foreach ($delCategories as $category) {
|
||||
if (is_array($cache->delConfig[$category])) {
|
||||
$keys = array_keys($cache->delConfig[$category]);
|
||||
|
||||
foreach ($keys as $key) {
|
||||
unset($newConfig[$category][$key]);
|
||||
unset($newSource[$category][$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$newCache = new Cache();
|
||||
$newCache->config = $newConfig;
|
||||
$newCache->source = $newSource;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue