]> git.mxchange.org Git - friendica.git/commitdiff
Preload Adapter Fix
authorPhilipp Holzer <admin@philipp.info>
Mon, 18 Feb 2019 13:00:34 +0000 (14:00 +0100)
committerPhilipp Holzer <admin@philipp.info>
Mon, 18 Feb 2019 13:02:09 +0000 (14:02 +0100)
src/Core/Config/Adapter/JITConfigAdapter.php
src/Core/Config/Adapter/JITPConfigAdapter.php
src/Core/Config/Adapter/PreloadConfigAdapter.php
src/Core/Config/Adapter/PreloadPConfigAdapter.php
src/Core/Config/Cache/ConfigCache.php

index 5d06dc2b3e73f6879e69da1340aa50c9dc8dde83..c0d680d2c9657458f2c7029c2dae01f731db905f 100644 (file)
@@ -33,10 +33,13 @@ class JITConfigAdapter extends AbstractDbaConfigAdapter implements IConfigAdapte
 
                $configs = DBA::select('config', ['v', 'k'], ['cat' => $cat]);
                while ($config = DBA::fetch($configs)) {
-                       $key = $config['k'];
+                       $key   = $config['k'];
+                       $value = $config['v'];
 
-                       $return[$key] = $config['v'];
-                       $this->in_db[$cat][$key] = true;
+                       if (isset($value) && $value !== '') {
+                               $return[$key] = $value;
+                               $this->in_db[$cat][$key] = true;
+                       }
                }
                DBA::close($configs);
 
index d3c38623b43d8794acea014e554ab8e9342e4b28..4485ee5df9ddd759cccec5352318acc3ef9b5e06 100644 (file)
@@ -29,10 +29,12 @@ class JITPConfigAdapter extends AbstractDbaConfigAdapter implements IPConfigAdap
                if (DBA::isResult($pconfigs)) {
                        while ($pconfig = DBA::fetch($pconfigs)) {
                                $key = $pconfig['k'];
+                               $value = $pconfig['v'];
 
-                               $return[$key] = $pconfig['v'];
-
-                               $this->in_db[$uid][$cat][$key] = true;
+                               if (isset($value) && $value !== '') {
+                                       $return[$key] = $value;
+                                       $this->in_db[$uid][$cat][$key] = true;
+                               }
                        }
                } else if ($cat != 'config') {
                        // Negative caching
index b1866a259d86567ed5fe4324dc87650925bb636b..d4ce6406b4442b4b815cc6d8d9ff59d328f88d83 100644 (file)
@@ -32,7 +32,10 @@ class PreloadConfigAdapter extends AbstractDbaConfigAdapter implements IConfigAd
 
                $configs = DBA::select('config', ['cat', 'v', 'k']);
                while ($config = DBA::fetch($configs)) {
-                       $return[$config['cat']][$config['k']] = $config['v'];
+                       $value = $config['v'];
+                       if (isset($value) && $value !== '') {
+                               $return[$config['cat']][$config['k']] = $value;
+                       }
                }
                DBA::close($configs);
 
index 857f2b17664035e83d99dda28e5f654fec90de5a..090d0f5c6f211975f5acf9754eddee6314f51325 100644 (file)
@@ -44,7 +44,10 @@ class PreloadPConfigAdapter extends AbstractDbaConfigAdapter implements IPConfig
 
                $pconfigs = DBA::select('pconfig', ['cat', 'v', 'k'], ['uid' => $uid]);
                while ($pconfig = DBA::fetch($pconfigs)) {
-                       $return[$pconfig['cat']][$pconfig['k']] = $pconfig['v'];
+                       $value = $pconfig['v'];
+                       if (isset($value) && $value !== '') {
+                               $return[$pconfig['cat']][$pconfig['k']] = $value;
+                       }
                }
                DBA::close($pconfigs);
 
index 54da327dba9e55b3d5c719a195d7a179ced2a4fe..4ebcc87482f044b278d0fdd626d47b97624fc9da 100644 (file)
@@ -36,11 +36,12 @@ class ConfigCache implements IConfigCache, IPConfigCache
                                $keys = array_keys($config[$category]);
 
                                foreach ($keys as $key) {
-                                       if (isset($config[$category][$key])) {
+                                       $value = $config[$category][$key];
+                                       if (isset($value) && $value !== '!<unset>!') {
                                                if ($overwrite) {
-                                                       $this->set($category, $key, $config[$category][$key]);
+                                                       $this->set($category, $key, $value);
                                                } else {
-                                                       $this->setDefault($category, $key, $config[$category][$key]);
+                                                       $this->setDefault($category, $key, $value);
                                                }
                                        }
                                }
@@ -132,9 +133,19 @@ class ConfigCache implements IConfigCache, IPConfigCache
         */
        public function loadP($uid, array $config)
        {
-               foreach ($config as $category => $values) {
-                       foreach ($values as $key => $value) {
-                               $this->setP($uid, $category, $key, $value);
+               $categories = array_keys($config);
+
+               foreach ($categories as $category) {
+                       if (isset($config[$category]) && is_array($config[$category])) {
+
+                               $keys = array_keys($config[$category]);
+
+                               foreach ($keys as $key) {
+                                       $value = $config[$category][$key];
+                                       if (isset($value) && $value !== '!<unset>!') {
+                                               $this->setP($uid, $category, $key, $value);
+                                       }
+                               }
                        }
                }
        }