[BUGFIX] Handle content with no markers in substituteMarkerArrayCached 56/45256/2
authorMarkus Klein <markus.klein@typo3.org>
Mon, 14 Dec 2015 22:12:47 +0000 (23:12 +0100)
committerAndreas Fernandez <typo3@scripting-base.de>
Tue, 15 Dec 2015 07:46:13 +0000 (08:46 +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/45256
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 9c286c0..dfa89df 100644 (file)
@@ -1897,31 +1897,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:
+                                               $GLOBALS['TSFE']->sys_page->storeHash($storeKey, $storeArr, 'substMarkArrayCached');
+                                       }
                                }
-
-                               // Setting cache:
-                               $this->substMarkerCache[$storeKey] = $storeArr;
-                               // Storing the cached data:
-                               $GLOBALS['TSFE']->sys_page->storeHash($storeKey, $storeArr, 'substMarkArrayCached');
                                $GLOBALS['TT']->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'])];
                $GLOBALS['TT']->pull();
                return $content;
        }