Fix multiple serialized values

This commit is contained in:
Philipp 2023-02-19 12:57:39 +01:00
parent 7560939d75
commit d772331b91
No known key found for this signature in database
GPG key ID: 24A7501396EB5432
4 changed files with 71 additions and 6 deletions

View file

@ -61,15 +61,13 @@ class DatabaseConfig implements IManageConfigValues
foreach ($setCache->getAll() as $category => $data) {
foreach ($data as $key => $value) {
$this->cache->set($category, $key, $value, Cache::SOURCE_DATA);
$this->database->insert('config', ['cat' => $category, 'k' => $key, 'v' => serialize($value)], Database::INSERT_UPDATE);
$this->set($category, $key, $value);
}
}
foreach ($delCache->getAll() as $category => $keys) {
foreach ($keys as $key => $value) {
$this->cache->delete($category, $key);
$this->database->delete('config', ['cat' => $category, 'k' => $key]);
$this->delete($category, $key);
}
}
@ -85,6 +83,10 @@ class DatabaseConfig implements IManageConfigValues
/** {@inheritDoc} */
public function set(string $cat, string $key, $value): bool
{
// In case someone or something already serialized a config entry, unserialize it first
// We serialize values just once
$value = SerializeUtil::maybeUnserialize($value);
$this->cache->set($cat, $key, $value, Cache::SOURCE_DATA);
return $this->database->insert('config', ['cat' => $cat, 'k' => $key, 'v' => serialize($value)], Database::INSERT_UPDATE);
}