]> git.mxchange.org Git - friendica.git/commitdiff
Bugfixings for getAllKeys()
authorPhilipp Holzer <admin@philipp.info>
Sun, 7 Oct 2018 20:14:05 +0000 (22:14 +0200)
committerPhilipp Holzer <admin@philipp.info>
Sun, 7 Oct 2018 20:14:05 +0000 (22:14 +0200)
src/Core/Cache.php
src/Core/Cache/DatabaseCacheDriver.php
src/Core/Cache/ICacheDriver.php
src/Core/Cache/MemcachedCacheDriver.php
src/Core/Console/Cache.php

index 7b9f6edd2c2ffbefba7e0a5d093ebcfb4433d131..b239af7d60bad23a8459ec6858769fc94a0e5991 100644 (file)
@@ -53,7 +53,7 @@ class Cache extends \Friendica\BaseObject
         *
         * @param string $prefix Prefix of the keys (optional)
         *
-        * @return array|null Null if the driver doesn't support this feature
+        * @return array Empty if the driver doesn't support this feature
         */
        public static function getAllKeys($prefix = null)
        {
index 9966457467cfbb6689fbb61cd3fd8a04036b5b2b..d90c6e4f18180f6777a316dbe1cf2d70249ce85f 100644 (file)
@@ -21,18 +21,18 @@ class DatabaseCacheDriver extends AbstractCacheDriver implements ICacheDriver
                if (empty($prefix)) {
                        $where = ['`expires` >= ?', DateTimeFormat::utcNow()];
                } else {
-                       $where = ['`expires` >= ? AND k LIKE CONCAT(?, \'%\')', DateTimeFormat::utcNow(), $prefix];
+                       $where = ['`expires` >= ? AND `k` LIKE CONCAT(?, \'%\')', DateTimeFormat::utcNow(), $prefix];
                }
 
                $stmt = DBA::select('cache', ['k'], $where);
 
-               $list = [];
+               $keys = [];
                while ($key = DBA::fetch($stmt)) {
-                       array_push($list, $key['k']);
+                       array_push($keys, $key['k']);
                }
                DBA::close($stmt);
 
-               return $list;
+               return $keys;
        }
 
        /**
index 0a206559ccbf908e4724600075445eb7df7fa143..2c04c5992578588611fd08fdefc1dd0d0ffb87f6 100644 (file)
@@ -16,7 +16,7 @@ interface ICacheDriver
         *
         * @param string prefix optional a prefix to search
         *
-        * @return array|null Null if it isn't supported by the cache driver
+        * @return array Empty if it isn't supported by the cache driver
         */
        public function getAllKeys($prefix = null);
 
index 62c3892860ff2ca8f9b62bc38b6ac741221f04c0..1a6b2a9aefbfa7d25e9d7369fe6e77b8147e1a91 100644 (file)
@@ -65,7 +65,7 @@ class MemcachedCacheDriver extends AbstractCacheDriver implements IMemoryCacheDr
                        return $this->filterArrayKeysByPrefix($keys, $prefix);
                } else {
                        logger('Memcached \'getAllKeys\' failed with ' . $this->memcached->getResultMessage(), LOGGER_ALL);
-                       return null;
+                       return [];
                }
        }
 
index 459a27e20bed216ce0392ec60d4e03f122e3a12a..1d93c3c011d12f150ca0103d7bf55b4cab3b92dc 100644 (file)
@@ -116,6 +116,7 @@ HELP;
                $count = 0;
                foreach ($keys as $key) {
                        $this->out($key);
+                       $count++;
                }
 
                $this->out($count . ' keys found');