[BUGFIX] Let RedirectCacheService not rely on having redirects cached 50/56050/2
authorAndreas Fernandez <a.fernandez@scripting-base.de>
Thu, 8 Mar 2018 07:58:15 +0000 (08:58 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Thu, 8 Mar 2018 21:48:03 +0000 (22:48 +0100)
RedirectCacheService::getRedirects() relies on having the redirects
cached. This assumption may lead to issues (e.g. in case a Redis server
fails), causing TypeErrors.

The code is changed to return the composed array in case the initial
cache request misses.

Resolves: #84070
Releases: master
Change-Id: I148db9ccbf28a2f93761fbf4b2cb632e27787b2d
Reviewed-on: https://review.typo3.org/56050
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Benjamin Franzke <bfr@qbus.de>
Tested-by: Benjamin Franzke <bfr@qbus.de>
Reviewed-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Tested-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/redirects/Classes/Service/RedirectCacheService.php

index b4c6028..289e3c8 100644 (file)
@@ -54,8 +54,7 @@ class RedirectCacheService
     {
         $redirects = $this->cache->get('redirects');
         if (!is_array($redirects)) {
-            $this->rebuild();
-            $redirects = $this->cache->get('redirects');
+            $redirects = $this->rebuild();
         }
         return $redirects;
     }
@@ -64,7 +63,7 @@ class RedirectCacheService
      * Rebuilds the cache for all redirects, grouped by host and by regular expressions.
      * Does not include deleted redirects, but includes the ones with dynamic starttime/endtime.
      */
-    public function rebuild()
+    public function rebuild(): array
     {
         $redirects = [];
         $this->flush();
@@ -85,6 +84,7 @@ class RedirectCacheService
             }
         }
         $this->cache->set('redirects', $redirects, ['redirects']);
+        return $redirects;
     }
 
     /**