[TASK] Simplify frontend page generation code 93/56893/4
authorHelmut Hummel <typo3@helhum.io>
Tue, 1 May 2018 16:57:06 +0000 (18:57 +0200)
committerMarkus Klein <markus.klein@typo3.org>
Fri, 11 May 2018 22:15:33 +0000 (00:15 +0200)
The additional isINTincScript check stems from the time
where this code was in a separate file, which
was included two times and page generation should be
skipped for the second inclusion. As INT scripts are only generated
during page rendering (or when fetching the page from cache)
we can safely remove this condition now.

Additionally, we can now easily get rid of the elseif
and move the page rendering preparation directly
after the same condition is checked later in the code flow.

This is fine, because this code does not need to be
executed before the lock is released. Last but not least
we clean up admin panel messages to clearly distinguish
between page generation and rendering preparation.

As this is a pure non breaking cleanup, this can
safely go into 8.7 branch as well.

Resolves: #84945
Releases: master, 8.7
Change-Id: If12b82a549d4cc47619c46f73c5423df70621b1b
Reviewed-on: https://review.typo3.org/56893
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php
typo3/sysext/frontend/Classes/Http/RequestHandler.php

index 271b177..266adc7 100644 (file)
@@ -3193,6 +3193,7 @@ class TypoScriptFrontendController
      */
     public function preparePageContentGeneration()
     {
      */
     public function preparePageContentGeneration()
     {
+        $this->getTimeTracker()->push('Prepare page content generation');
         if ($this->page['content_from_pid'] > 0) {
             // make REAL copy of TSFE object - not reference!
             $temp_copy_TSFE = clone $this;
         if ($this->page['content_from_pid'] > 0) {
             // make REAL copy of TSFE object - not reference!
             $temp_copy_TSFE = clone $this;
@@ -3330,6 +3331,7 @@ class TypoScriptFrontendController
 
         // Global content object
         $this->newCObj();
 
         // Global content object
         $this->newCObj();
+        $this->getTimeTracker()->pull();
     }
 
     /**
     }
 
     /**
index 5520013..89e0b13 100644 (file)
@@ -174,6 +174,7 @@ class RequestHandler implements RequestHandlerInterface
         $this->timeTracker->pull();
         // Get from cache
         $this->timeTracker->push('Get Page from cache', '');
         $this->timeTracker->pull();
         // Get from cache
         $this->timeTracker->push('Get Page from cache', '');
+        // Locks may be acquired here
         $this->controller->getFromCache();
         $this->timeTracker->pull();
         // Get config if not already gotten
         $this->controller->getFromCache();
         $this->timeTracker->pull();
         // Get config if not already gotten
@@ -198,8 +199,8 @@ class RequestHandler implements RequestHandlerInterface
 
         // Generate page
         $this->controller->setUrlIdToken();
 
         // Generate page
         $this->controller->setUrlIdToken();
-        $this->timeTracker->push('Page generation', '');
         if ($this->controller->isGeneratePage()) {
         if ($this->controller->isGeneratePage()) {
+            $this->timeTracker->push('Page generation');
             $this->controller->generatePage_preProcessing();
             $temp_theScript = $this->controller->generatePage_whichScript();
             if ($temp_theScript) {
             $this->controller->generatePage_preProcessing();
             $temp_theScript = $this->controller->generatePage_whichScript();
             if ($temp_theScript) {
@@ -207,21 +208,21 @@ class RequestHandler implements RequestHandlerInterface
             } else {
                 $this->controller->preparePageContentGeneration();
                 // Content generation
             } else {
                 $this->controller->preparePageContentGeneration();
                 // Content generation
-                if (!$this->controller->isINTincScript()) {
-                    PageGenerator::renderContent();
-                    $this->controller->setAbsRefPrefix();
-                }
+                PageGenerator::renderContent();
+                $this->controller->setAbsRefPrefix();
             }
             $this->controller->generatePage_postProcessing();
             }
             $this->controller->generatePage_postProcessing();
-        } elseif ($this->controller->isINTincScript()) {
-            $this->controller->preparePageContentGeneration();
+            $this->timeTracker->pull();
         }
         $this->controller->releaseLocks();
         }
         $this->controller->releaseLocks();
-        $this->timeTracker->pull();
 
 
-        // Render non-cached parts
+        // Render non-cached page parts by replacing placeholders which are taken from cache or added during page generation
         if ($this->controller->isINTincScript()) {
         if ($this->controller->isINTincScript()) {
-            $this->timeTracker->push('Non-cached objects', '');
+            if (!$this->controller->isGeneratePage()) {
+                // When page was generated, this was already called. Avoid calling this twice.
+                $this->controller->preparePageContentGeneration();
+            }
+            $this->timeTracker->push('Non-cached objects');
             $this->controller->INTincScript();
             $this->timeTracker->pull();
         }
             $this->controller->INTincScript();
             $this->timeTracker->pull();
         }