[BUGFIX] Handle content with no markers in substituteMarkerArrayCached 55/45255/2
authorMarkus Klein <markus.klein@typo3.org>
Mon, 14 Dec 2015 22:09:54 +0000 (23:09 +0100)
committerAndreas Fernandez <typo3@scripting-base.de>
Tue, 15 Dec 2015 07:35:53 +0000 (08:35 +0100)
If the content has no markers at all, the full content
needs to be returned.
Additionally, the result does not need to be cached
if no markers are present.

Resolves: #72224
Releases: master, 6.2
Change-Id: I8fd39ab705eaa2217bba4fd5a069d940e677ea47
Reviewed-on: https://review.typo3.org/45255
Reviewed-by: Daniel Goerz <ervaude@gmail.com>
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php

index bb9a4ed..8ab9258 100644 (file)
@@ -2229,31 +2229,34 @@ class ContentObjectRenderer
                         $storeArr['c'] = preg_split($regex, $content);
                         $storeArr['k'] = $keyList[0];
                     }
+                    if (!empty($storeArr)) {
+                        // Setting cache:
+                        $this->substMarkerCache[$storeKey] = $storeArr;
+                        // Storing the cached data:
+                        $this->getTypoScriptFrontendController()->sys_page->storeHash($storeKey, $storeArr, 'substMarkArrayCached');
+                    }
                 }
-
-                // Setting cache:
-                $this->substMarkerCache[$storeKey] = $storeArr;
-                // Storing the cached data:
-                $this->getTypoScriptFrontendController()->sys_page->storeHash($storeKey, $storeArr, 'substMarkArrayCached');
                 $timeTracker->setTSlogMessage('Parsing', 0);
             }
         }
-        // Substitution/Merging:
-        // Merging content types together, resetting
-        $valueArr = array_merge($markContentArray, $subpartContentArray, $wrappedSubpartContentArray);
-        $wSCA_reg = array();
-        $content = '';
-        // Traversing the keyList array and merging the static and dynamic content
-        foreach ($storeArr['k'] as $n => $keyN) {
-            $content .= $storeArr['c'][$n];
-            if (!is_array($valueArr[$keyN])) {
-                $content .= $valueArr[$keyN];
-            } else {
-                $content .= $valueArr[$keyN][(int)$wSCA_reg[$keyN] % 2];
-                $wSCA_reg[$keyN]++;
+        if (!empty($storeArr['k']) && is_array($storeArr['k'])) {
+            // Substitution/Merging:
+            // Merging content types together, resetting
+            $valueArr = array_merge($markContentArray, $subpartContentArray, $wrappedSubpartContentArray);
+            $wSCA_reg = array();
+            $content = '';
+            // Traversing the keyList array and merging the static and dynamic content
+            foreach ($storeArr['k'] as $n => $keyN) {
+                $content .= $storeArr['c'][$n];
+                if (!is_array($valueArr[$keyN])) {
+                    $content .= $valueArr[$keyN];
+                } else {
+                    $content .= $valueArr[$keyN][(int)$wSCA_reg[$keyN] % 2];
+                    $wSCA_reg[$keyN]++;
+                }
             }
+            $content .= $storeArr['c'][count($storeArr['k'])];
         }
-        $content .= $storeArr['c'][count($storeArr['k'])];
         $timeTracker->pull();
         return $content;
     }