diff --git a/src/Core/Config/ValueObject/Cache.php b/src/Core/Config/ValueObject/Cache.php index c427996c3..2bac625ad 100644 --- a/src/Core/Config/ValueObject/Cache.php +++ b/src/Core/Config/ValueObject/Cache.php @@ -182,6 +182,8 @@ class Cache $key == 'password' && is_string($value)) { $this->config[$cat][$key] = new HiddenString((string)$value); + } else if (is_string($value)) { + $this->config[$cat][$key] = self::toConfigValue($value); } else { $this->config[$cat][$key] = $value; } @@ -191,6 +193,35 @@ class Cache return true; } + /** + * Formats a DB value to a config value + * - null = The db-value isn't set + * - bool = The db-value is either '0' or '1' + * - array = The db-value is a serialized array + * - string = The db-value is a string + * + * Keep in mind that there aren't any numeric/integer config values in the database + * + * @param string|null $value + * + * @return null|array|string + */ + public static function toConfigValue(?string $value) + { + if (!isset($value)) { + return null; + } + + switch (true) { + // manage array value + case preg_match("|^a:[0-9]+:{.*}$|s", $value): + return unserialize($value); + + default: + return $value; + } + } + /** * Deletes a value from the config cache. *