[BUGFIX] Make global TSFE and TT a reference to the class members 89/38489/3
authorAnja Leichsenring <aleichsenring@ab-softlab.de>
Sun, 5 Apr 2015 10:40:12 +0000 (12:40 +0200)
committerBenjamin Mack <benni@typo3.org>
Mon, 20 Apr 2015 08:32:10 +0000 (10:32 +0200)
The global variables $GLOBALS['TSFE'] and ['TT'] are modified in
some places throughout FE rendering.
Since those public objects should only be mirrors of the protected
members of the RequestHandler, we need to make the global variables
a reference to the protected members.

Be aware that this is a dirty workaround and actually bypasses
the protected access of the members by making them changable
via the global variables.

Change-Id: I542f382ee42bdbacc6bad7d74dfb69dfe6fcca88
Resolves: #66278
Relates: #65914
Releases: master
Reviewed-on: http://review.typo3.org/38489
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Andreas Fernandez <andreas.fernandez@aspedia.de>
Tested-by: Andreas Fernandez <andreas.fernandez@aspedia.de>
Reviewed-by: Benjamin Mack <benni@typo3.org>
Tested-by: Benjamin Mack <benni@typo3.org>
typo3/sysext/frontend/Classes/RequestHandler.php

index 01a6445..e1be073 100644 (file)
@@ -336,7 +336,11 @@ class RequestHandler implements RequestHandlerInterface {
                        $this->timeTracker = new NullTimeTracker();
                }
 
-               $GLOBALS['TT'] = $this->timeTracker;
+               // We have to define this as reference here, because there is code around
+               // which exchanges the TT object in the global variable. The reference ensures
+               // that the $timeTracker member always works on the same object as the global variable.
+               // This is a dirty workaround and bypasses the protected access modifier of the $timeTracker member.
+               $GLOBALS['TT'] = &$this->timeTracker;
                $this->timeTracker->start();
        }
 
@@ -358,6 +362,10 @@ class RequestHandler implements RequestHandlerInterface {
                        GeneralUtility::_GP('RDCT')
                );
                // setting the global variable for the controller
-               $GLOBALS['TSFE'] = $this->controller;
+               // We have to define this as reference here, because there is code around
+               // which exchanges the TSFE object in the global variable. The reference ensures
+               // that the $controller member always works on the same object as the global variable.
+               // This is a dirty workaround and bypasses the protected access modifier of the controller member.
+               $GLOBALS['TSFE'] = &$this->controller;
        }
 }