mirror of
https://github.com/friendica/friendica
synced 2024-11-18 04:23:41 +00:00
Use toConfigValue in case of serialized, legacy data
This commit is contained in:
parent
10f3de0aa2
commit
88b3effc18
1 changed files with 31 additions and 0 deletions
|
@ -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.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue