]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/Config/Adapter/PreloadPConfigAdapter.php
Merge branch 'master' into develop
[friendica.git] / src / Core / Config / Adapter / PreloadPConfigAdapter.php
index 1af526b7c19c40644cad8db10b9dfd662bfa1f04..838f3763dfcd5f26849b3c915bbbd1baa957696b 100644 (file)
@@ -49,7 +49,7 @@ class PreloadPConfigAdapter extends AbstractDbaConfigAdapter implements IPConfig
 
                $pconfigs = DBA::select('pconfig', ['cat', 'v', 'k'], ['uid' => $uid]);
                while ($pconfig = DBA::fetch($pconfigs)) {
-                       $value = $pconfig['v'];
+                       $value = $this->toConfigValue($pconfig['v']);
                        if (isset($value)) {
                                $return[$pconfig['cat']][$pconfig['k']] = $value;
                        }
@@ -76,8 +76,7 @@ class PreloadPConfigAdapter extends AbstractDbaConfigAdapter implements IPConfig
 
                $config = DBA::selectFirst('pconfig', ['v'], ['uid' => $uid, 'cat' => $cat, 'k' => $key]);
                if (DBA::isResult($config)) {
-                       // manage array value
-                       $value = (preg_match("|^a:[0-9]+:{.*}$|s", $config['v']) ? unserialize($config['v']) : $config['v']);
+                       $value = $this->toConfigValue($config['v']);
 
                        if (isset($value)) {
                                return $value;
@@ -102,13 +101,13 @@ class PreloadPConfigAdapter extends AbstractDbaConfigAdapter implements IPConfig
                // So we have to do the conversion here so that the compare below works.
                // The exception are array values.
                $compare_value = !is_array($value) ? (string)$value : $value;
+               $stored_value = $this->get($uid, $cat, $key);
 
-               if ($this->get($uid, $cat, $key) === $compare_value) {
+               if (isset($stored_value) && $stored_value === $compare_value) {
                        return true;
                }
 
-               // manage array value
-               $dbvalue = is_array($value) ? serialize($value) : $value;
+               $dbvalue = $this->toDbValue($value);
 
                return DBA::update('pconfig', ['v' => $dbvalue], ['uid' => $uid, 'cat' => $cat, 'k' => $key], true);
        }