]> git.mxchange.org Git - friendica.git/commitdiff
Merge pull request #11692 from MrPetovan/bug/fatal-errors
authorPhilipp <admin+Github@philipp.info>
Sun, 26 Jun 2022 11:34:23 +0000 (13:34 +0200)
committerGitHub <noreply@github.com>
Sun, 26 Jun 2022 11:34:23 +0000 (13:34 +0200)
Convert potential spaces in Memcache(d) key names

src/Core/Cache/Type/MemcacheCache.php
src/Core/Cache/Type/MemcachedCache.php
src/Protocol/OStatus.php
tests/src/Core/Cache/CacheTest.php

index 441c64c3a0bb01fce61299280d2abc30f6d59f84..225c338911715c06205f2eae3c4100f07652bcc4 100644 (file)
@@ -68,6 +68,17 @@ class MemcacheCache extends AbstractCache implements ICanCacheInMemory
                }
        }
 
+       /**
+        * Memcache doesn't allow spaces in keys
+        *
+        * @param string $key
+        * @return string
+        */
+       protected function getCacheKey(string $key): string
+       {
+               return str_replace(' ', '_', parent::getCacheKey($key));
+       }
+
        /**
         * (@inheritdoc)
         */
index d86906de7672fb0bcc2e05af60afe0dcb3c869b7..2d8b4e1c2f99d47a1540ddca7d8aecfe09e7fd1d 100644 (file)
@@ -93,6 +93,17 @@ class MemcachedCache extends AbstractCache implements ICanCacheInMemory
                }
        }
 
+       /**
+        * Memcached doesn't allow spaces in keys
+        *
+        * @param string $key
+        * @return string
+        */
+       protected function getCacheKey(string $key): string
+       {
+               return str_replace(' ', '_', parent::getCacheKey($key));
+       }
+
        /**
         * (@inheritdoc)
         */
index 90e52d673db1f2314487d5d220ce33adb837c353..36dbb06c8446db7eae69b6cb67173a3adc177177 100644 (file)
@@ -2017,7 +2017,7 @@ class OStatus
         * cache or it is empty
         *
         * @param string  $owner_nick  Nickname of the feed owner
-        * @param string  $last_update Date of the last update
+        * @param string  $last_update Date of the last update (in "Y-m-d H:i:s" format)
         * @param integer $max_items   Number of maximum items to fetch
         * @param string  $filter      Feed items filter (activity, posts or comments)
         * @param boolean $nocache     Wether to bypass caching
index 88154c9d22cd899d7e4989e3a36de8641fedca6f..c249aefbfa11fd2710e334a8299dfd91d3b38185 100644 (file)
@@ -237,4 +237,13 @@ abstract class CacheTest extends MockedTest
                self::assertNotContains('value1', $list);
                self::assertNotContains('value2', $list);
        }
+
+       /**
+        * @small
+        */
+       public function testSpaceInKey()
+       {
+               self::assertTrue($this->instance->set('key space', 'value'));
+               self::assertEquals('value', $this->instance->get('key space'));
+       }
 }