[TASK] Use consistent checks for USER_INT logic 03/62303/4
authorBenni Mack <benni@typo3.org>
Tue, 12 Nov 2019 13:27:24 +0000 (14:27 +0100)
committerGeorg Ringer <georg.ringer@gmail.com>
Tue, 12 Nov 2019 17:30:41 +0000 (18:30 +0100)
A few places in TYPO3 Core do manual checks if there
are non-cacheables on a page, which could be simplified
by just using the $TSFE->isINTincScript() method.

In addition, a safer check for a NON-empty INTincScript
value is used, instead of just a typecheck of array.

Resolves: #89652
Releases: master
Change-Id: I24b2b55b3705927720e36181926cf6e752bf0f66
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62303
Tested-by: Markus Klein <markus.klein@typo3.org>
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php
typo3/sysext/frontend/Classes/Http/RequestHandler.php
typo3/sysext/frontend/Tests/Unit/Http/RequestHandlerTest.php

index 2e0cedc..46255c9 100644 (file)
@@ -2021,7 +2021,7 @@ class TypoScriptFrontendController implements LoggerAwareInterface
         }
 
         // If config is not set by the cache (which would be a major mistake somewhere) OR if INTincScripts-include-scripts have been registered, then we must parse the template in order to get it
-        if (empty($this->config) || is_array($this->config['INTincScript']) || $this->context->getPropertyFromAspect('typoscript', 'forcedTemplateParsing')) {
+        if (empty($this->config) || $this->isINTincScript() || $this->context->getPropertyFromAspect('typoscript', 'forcedTemplateParsing')) {
             $timeTracker = $this->getTimeTracker();
             $timeTracker->push('Parse template');
             // Start parsing the TS template. Might return cached version.
@@ -3105,11 +3105,11 @@ class TypoScriptFrontendController implements LoggerAwareInterface
     /**
      * Determines if there are any INTincScripts to include.
      *
-     * @return bool Returns TRUE if scripts are found and no URL handler is active.
+     * @return bool Returns TRUE if scripts are found
      */
     public function isINTincScript()
     {
-        return is_array($this->config['INTincScript']);
+        return !empty($this->config['INTincScript']) && is_array($this->config['INTincScript']);
     }
 
     /********************************************
index 997b456..d634df7 100644 (file)
@@ -860,7 +860,7 @@ class RequestHandler implements RequestHandlerInterface
         }
         // Page content
         $pageRenderer->addBodyContent(LF . $pageContent);
-        if (!empty($controller->config['INTincScript']) && is_array($controller->config['INTincScript'])) {
+        if ($controller->isINTincScript()) {
             // Store the serialized pageRenderer in configuration
             $controller->config['INTincScript_ext']['pageRenderer'] = serialize($pageRenderer);
             // Render complete page, keep placeholders for JavaScript and CSS
index 0f201d8..bb01a42 100644 (file)
@@ -233,6 +233,7 @@ class RequestHandlerTest extends UnitTestCase
         $tsfe = $this->prophesize(TypoScriptFrontendController::class);
         $tsfe->generatePageTitle()->willReturn('');
         $tsfe->INTincScript_loadJSCode()->shouldBeCalled();
+        $tsfe->isINTincScript()->shouldBeCalled();
         $tsfe->cObj = $cObj->reveal();
         $tsfe->tmpl = $tmpl->reveal();
         $tsfe->page = [
@@ -268,6 +269,7 @@ class RequestHandlerTest extends UnitTestCase
         $tsfe = $this->prophesize(TypoScriptFrontendController::class);
         $tsfe->generatePageTitle()->willReturn('');
         $tsfe->INTincScript_loadJSCode()->shouldBeCalled();
+        $tsfe->isINTincScript()->shouldBeCalled();
         $tsfe->cObj = $cObj->reveal();
         $tsfe->tmpl = $tmpl->reveal();
         $tsfe->config = [
@@ -306,6 +308,7 @@ class RequestHandlerTest extends UnitTestCase
         $tsfe = $this->prophesize(TypoScriptFrontendController::class);
         $tsfe->generatePageTitle()->willReturn('');
         $tsfe->INTincScript_loadJSCode()->shouldBeCalled();
+        $tsfe->isINTincScript()->shouldBeCalled();
         $tsfe->cObj = $cObj->reveal();
         $tsfe->tmpl = $tmpl->reveal();
         $tsfe->config = [
@@ -399,6 +402,7 @@ class RequestHandlerTest extends UnitTestCase
         $tsfe = $this->prophesize(TypoScriptFrontendController::class);
         $tsfe->generatePageTitle()->willReturn('');
         $tsfe->INTincScript_loadJSCode()->shouldBeCalled();
+        $tsfe->isINTincScript()->shouldBeCalled();
         $tsfe->cObj = $cObj->reveal();
         $tsfe->tmpl = $tmpl->reveal();
         $tsfe->config = [