[!!!][TASK] Make TimeTracker a singleton 20/46520/11
authorBenni Mack <benni@typo3.org>
Mon, 8 Feb 2016 19:47:08 +0000 (20:47 +0100)
committerSusanne Moog <typo3@susannemoog.de>
Sun, 21 Feb 2016 11:40:39 +0000 (12:40 +0100)
By declaring the TimeTracker class as singleton, there is no
need anymore for $GLOBALS['TT'].

Change-Id: I412fbdcbd2c60dcaae4dc592bea48a7d059f7e95
Resolves: #73504
Releases: master
Reviewed-on: https://review.typo3.org/46520
Reviewed-by: Michiel Roos <michiel@maxserv.com>
Tested-by: Michiel Roos <michiel@maxserv.com>
Reviewed-by: Daniel Goerz <ervaude@gmail.com>
Tested-by: Daniel Goerz <ervaude@gmail.com>
Reviewed-by: Susanne Moog <typo3@susannemoog.de>
Tested-by: Susanne Moog <typo3@susannemoog.de>
27 files changed:
typo3/sysext/core/Classes/Database/DatabaseConnection.php
typo3/sysext/core/Classes/Error/ErrorHandler.php
typo3/sysext/core/Classes/Service/AbstractService.php
typo3/sysext/core/Classes/TimeTracker/TimeTracker.php
typo3/sysext/core/Classes/TypoScript/Parser/TypoScriptParser.php
typo3/sysext/core/Classes/TypoScript/TemplateService.php
typo3/sysext/core/Documentation/Changelog/master/Breaking-73504-MakeTimeTrackerASingleton.rst [new file with mode: 0644]
typo3/sysext/frontend/Classes/Configuration/TypoScript/ConditionMatching/ConditionMatcher.php
typo3/sysext/frontend/Classes/ContentObject/ContentContentObject.php
typo3/sysext/frontend/Classes/ContentObject/ContentObjectArrayContentObject.php
typo3/sysext/frontend/Classes/ContentObject/ContentObjectArrayInternalContentObject.php
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
typo3/sysext/frontend/Classes/ContentObject/Menu/AbstractMenuContentObject.php
typo3/sysext/frontend/Classes/ContentObject/RecordsContentObject.php
typo3/sysext/frontend/Classes/ContentObject/UserContentObject.php
typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php
typo3/sysext/frontend/Classes/Http/EidRequestHandler.php
typo3/sysext/frontend/Classes/Http/RequestHandler.php
typo3/sysext/frontend/Classes/Page/PageGenerator.php
typo3/sysext/frontend/Classes/View/AdminPanelView.php
typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php
typo3/sysext/frontend/Tests/Unit/Controller/TypoScriptFrontendControllerTest.php
typo3/sysext/indexed_search/Classes/Controller/SearchFormController.php
typo3/sysext/indexed_search/Classes/Domain/Repository/IndexSearchRepository.php
typo3/sysext/indexed_search/Classes/Indexer.php
typo3/sysext/indexed_search_mysql/Classes/Hook/MysqlFulltextIndexHook.php
typo3/sysext/saltedpasswords/Classes/SaltedPasswordService.php

index f6857c3..2313b96 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Core\Database;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\TimeTracker\TimeTracker;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\StringUtility;
 
@@ -1866,7 +1867,7 @@ class DatabaseConnection
         ) {
             // Raw HTML output
             $explainMode = 1;
-        } elseif ((int)$this->explainOutput == 3 && is_object($GLOBALS['TT'])) {
+        } elseif ((int)$this->explainOutput == 3) {
             // Embed the output into the TS admin panel
             $explainMode = 2;
         } else {
@@ -1924,7 +1925,9 @@ class DatabaseConnection
                 if ($explainMode == 1) {
                     \TYPO3\CMS\Core\Utility\DebugUtility::debug($data, 'Tables: ' . $from_table, 'DB SQL EXPLAIN');
                 } elseif ($explainMode == 2) {
-                    $GLOBALS['TT']->setTSselectQuery($data);
+                    /** @var TimeTracker $timeTracker */
+                    $timeTracker = GeneralUtility::makeInstance(TimeTracker::class);
+                    $timeTracker->setTSselectQuery($data);
                 }
             }
             return true;
index 0c49916..b223cef 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Core\Error;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\TimeTracker\TimeTracker;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
@@ -210,11 +211,11 @@ class ErrorHandler implements ErrorHandlerInterface
     }
 
     /**
-     * @return \TYPO3\CMS\Core\TimeTracker\TimeTracker
+     * @return TimeTracker
      */
     protected function getTimeTracker()
     {
-        return $GLOBALS['TT'];
+        return GeneralUtility::makeInstance(TimeTracker::class);
     }
 
     /**
index 15cb9e6..fba8f04 100644 (file)
@@ -13,6 +13,8 @@ namespace TYPO3\CMS\Core\Service;
  *
  * The TYPO3 project - inspiring people to share!
  */
+use TYPO3\CMS\Core\TimeTracker\TimeTracker;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
  * Parent class for "Services" classes
@@ -151,7 +153,7 @@ abstract class AbstractService
     public function devLog($msg, $severity = 0, $dataVar = false)
     {
         if ($this->writeDevLog) {
-            \TYPO3\CMS\Core\Utility\GeneralUtility::devLog($msg, $this->info['serviceKey'], $severity, $dataVar);
+            GeneralUtility::devLog($msg, $this->info['serviceKey'], $severity, $dataVar);
         }
     }
 
@@ -165,9 +167,9 @@ abstract class AbstractService
     public function errorPush($errNum = T3_ERR_SV_GENERAL, $errMsg = 'Unspecified error occurred')
     {
         array_push($this->error, array('nr' => $errNum, 'msg' => $errMsg));
-        if (is_object($GLOBALS['TT'])) {
-            $GLOBALS['TT']->setTSlogMessage($errMsg, 2);
-        }
+        /** @var \TYPO3\CMS\Core\TimeTracker\TimeTracker $timeTracker */
+        $timeTracker = GeneralUtility::makeInstance(TimeTracker::class);
+        $timeTracker->setTSlogMessage($errMsg, 2);
     }
 
     /**
@@ -261,7 +263,7 @@ abstract class AbstractService
     public function checkExec($progList)
     {
         $ret = true;
-        $progList = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $progList, true);
+        $progList = GeneralUtility::trimExplode(',', $progList, true);
         foreach ($progList as $prog) {
             if (!\TYPO3\CMS\Core\Utility\CommandUtility::checkCommand($prog)) {
                 // Program not found
@@ -296,7 +298,7 @@ abstract class AbstractService
     public function checkInputFile($absFile)
     {
         $checkResult = false;
-        if (\TYPO3\CMS\Core\Utility\GeneralUtility::isAllowedAbsPath($absFile) && @is_file($absFile)) {
+        if (GeneralUtility::isAllowedAbsPath($absFile) && @is_file($absFile)) {
             if (@is_readable($absFile)) {
                 $checkResult = $absFile;
             } else {
@@ -339,7 +341,7 @@ abstract class AbstractService
         if (!$absFile) {
             $absFile = $this->tempFile($this->prefixId);
         }
-        if ($absFile && \TYPO3\CMS\Core\Utility\GeneralUtility::isAllowedAbsPath($absFile)) {
+        if ($absFile && GeneralUtility::isAllowedAbsPath($absFile)) {
             if ($fd = @fopen($absFile, 'wb')) {
                 @fwrite($fd, $content);
                 @fclose($fd);
@@ -359,7 +361,7 @@ abstract class AbstractService
      */
     public function tempFile($filePrefix)
     {
-        $absFile = \TYPO3\CMS\Core\Utility\GeneralUtility::tempnam($filePrefix);
+        $absFile = GeneralUtility::tempnam($filePrefix);
         if ($absFile) {
             $ret = $absFile;
             $this->registerTempFile($absFile);
@@ -393,7 +395,7 @@ abstract class AbstractService
     public function unlinkTempFiles()
     {
         foreach ($this->tempFiles as $absFile) {
-            \TYPO3\CMS\Core\Utility\GeneralUtility::unlink_tempfile($absFile);
+            GeneralUtility::unlink_tempfile($absFile);
         }
         $this->tempFiles = array();
     }
index 4c32456..6f43dcb 100755 (executable)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Core\TimeTracker;
  */
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Imaging\IconFactory;
+use TYPO3\CMS\Core\SingletonInterface;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
@@ -22,7 +23,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
  *
  * Is used to register how much time is used with operations in TypoScript
  */
-class TimeTracker
+class TimeTracker implements SingletonInterface
 {
 
     /**
index aa93a41..a820608 100644 (file)
@@ -764,7 +764,7 @@ class TypoScriptParser
      * If "TT" is a global object (as it is in the frontend when backend users are logged in) the message will be registered here as well.
      *
      * @param string $err The error message string
-     * @param int $num The error severity (in the scale of $GLOBALS['TT']->setTSlogMessage: Approx: 2=warning, 1=info, 0=nothing, 3=fatal.)
+     * @param int $num The error severity (in the scale of TimeTracker::setTSlogMessage: Approx: 2=warning, 1=info, 0=nothing, 3=fatal.)
      * @return void
      */
     public function error($err, $num = 2)
@@ -1305,7 +1305,7 @@ class TypoScriptParser
      */
     protected function getTimeTracker()
     {
-        return isset($GLOBALS['TT']) ? $GLOBALS['TT'] : null;
+        return GeneralUtility::makeInstance(TimeTracker::class);
     }
 
     /**
index 02232ec..0d812ca 100644 (file)
@@ -1730,6 +1730,6 @@ class TemplateService
      */
     protected function getTimeTracker()
     {
-        return $GLOBALS['TT'];
+        return GeneralUtility::makeInstance(TimeTracker::class);
     }
 }
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Breaking-73504-MakeTimeTrackerASingleton.rst b/typo3/sysext/core/Documentation/Changelog/master/Breaking-73504-MakeTimeTrackerASingleton.rst
new file mode 100644 (file)
index 0000000..57c796d
--- /dev/null
@@ -0,0 +1,26 @@
+===============================================
+Breaking: #73504 - Make TimeTracker a singleton
+===============================================
+
+Description
+===========
+
+The class ``\TYPO3\CMS\Core\TimeTracker\TimeTracker`` has been marked as singleton and is no longer stored in ``$GLOBALS['TT']``.
+
+
+Impact
+======
+
+Using methods of ``$GLOBALS['TT']`` will result in a fatal error.
+
+
+Affected Installations
+======================
+
+All installations or 3rd party extensions using ``$GLOBALS['TT']``.
+
+
+Migration
+=========
+
+Use ``\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\TimeTracker\TimeTracker::class)`` instead.
index 24b068e..f2dd60b 100644 (file)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Frontend\Configuration\TypoScript\ConditionMatching;
  */
 
 use TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher;
+use TYPO3\CMS\Core\TimeTracker\TimeTracker;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
@@ -195,10 +196,10 @@ class ConditionMatcher extends AbstractConditionMatcher
     }
 
     /**
-     * @return \TYPO3\CMS\Core\TimeTracker\TimeTracker
+     * @return TimeTracker
      */
     protected function getTimeTracker()
     {
-        return $GLOBALS['TT'];
+        return GeneralUtility::makeInstance(TimeTracker::class);
     }
 }
index b615c81..b0b9c0b 100644 (file)
@@ -162,6 +162,6 @@ class ContentContentObject extends AbstractContentObject
      */
     protected function getTimeTracker()
     {
-        return $GLOBALS['TT'];
+        return GeneralUtility::makeInstance(TimeTracker::class);
     }
 }
index d073dec..b66bcf8 100644 (file)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Frontend\ContentObject;
  */
 
 use TYPO3\CMS\Core\TimeTracker\TimeTracker;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
  * Contains COA class object.
@@ -53,6 +54,6 @@ class ContentObjectArrayContentObject extends AbstractContentObject
      */
     protected function getTimeTracker()
     {
-        return $GLOBALS['TT'];
+        return GeneralUtility::makeInstance(TimeTracker::class);
     }
 }
index b6ba8a9..682c934 100644 (file)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Frontend\ContentObject;
  */
 
 use TYPO3\CMS\Core\TimeTracker\TimeTracker;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
 
 /**
@@ -49,7 +50,7 @@ class ContentObjectArrayInternalContentObject extends AbstractContentObject
      */
     protected function getTimeTracker()
     {
-        return $GLOBALS['TT'];
+        return GeneralUtility::makeInstance(TimeTracker::class);
     }
 
     /**
index ed215e7..ee21e9b 100644 (file)
@@ -29,6 +29,7 @@ use TYPO3\CMS\Core\Resource\ProcessedFile;
 use TYPO3\CMS\Core\Resource\ResourceFactory;
 use TYPO3\CMS\Core\Service\DependencyOrderingService;
 use TYPO3\CMS\Core\Service\MarkerBasedTemplateService;
+use TYPO3\CMS\Core\TimeTracker\TimeTracker;
 use TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser;
 use TYPO3\CMS\Core\TypoScript\TemplateService;
 use TYPO3\CMS\Core\Utility\ArrayUtility;
@@ -8327,11 +8328,11 @@ class ContentObjectRenderer
     }
 
     /**
-     * @return \TYPO3\CMS\Core\TimeTracker\TimeTracker
+     * @return TimeTracker
      */
     protected function getTimeTracker()
     {
-        return $GLOBALS['TT'];
+        return GeneralUtility::makeInstance(TimeTracker::class);
     }
 
     /**
index d4b2182..952ec3c 100644 (file)
@@ -2213,7 +2213,7 @@ abstract class AbstractMenuContentObject
      */
     protected function getTimeTracker()
     {
-        return $GLOBALS['TT'];
+        return GeneralUtility::makeInstance(TimeTracker::class);
     }
 
     /**
index f622934..38c03ca 100644 (file)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Frontend\ContentObject;
  */
 
 use TYPO3\CMS\Core\Database\RelationHandler;
+use TYPO3\CMS\Core\TimeTracker\TimeTracker;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Frontend\Category\Collection\CategoryCollection;
 
@@ -225,12 +226,10 @@ class RecordsContentObject extends AbstractContentObject
     }
 
     /**
-     * Wrapper around the $GLOBALS['TT'] variable
-     *
-     * @return \TYPO3\CMS\Core\TimeTracker\TimeTracker
+     * @return TimeTracker
      */
     protected function getTimeTracker()
     {
-        return $GLOBALS['TT'];
+        return GeneralUtility::makeInstance(TimeTracker::class);
     }
 }
index 005b947..225f8dc 100644 (file)
@@ -13,6 +13,8 @@ namespace TYPO3\CMS\Frontend\ContentObject;
  *
  * The TYPO3 project - inspiring people to share!
  */
+use TYPO3\CMS\Core\TimeTracker\TimeTracker;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
  * Contains USER class object.
@@ -51,10 +53,10 @@ class UserContentObject extends AbstractContentObject
     }
 
     /**
-     * @return \TYPO3\CMS\Core\TimeTracker\TimeTracker
+     * @return TimeTracker
      */
     protected function getTimeTracker()
     {
-        return $GLOBALS['TT'];
+        return GeneralUtility::makeInstance(TimeTracker::class);
     }
 }
index ea5313d..2eb867a 100644 (file)
@@ -29,6 +29,7 @@ use TYPO3\CMS\Core\Messaging\ErrorpageMessage;
 use TYPO3\CMS\Core\Page\PageRenderer;
 use TYPO3\CMS\Core\Resource\StorageRepository;
 use TYPO3\CMS\Core\Service\DependencyOrderingService;
+use TYPO3\CMS\Core\TimeTracker\TimeTracker;
 use TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser;
 use TYPO3\CMS\Core\TypoScript\TemplateService;
 use TYPO3\CMS\Core\Utility\ArrayUtility;
@@ -4717,11 +4718,11 @@ class TypoScriptFrontendController
     }
 
     /**
-     * @return \TYPO3\CMS\Core\TimeTracker\TimeTracker
+     * @return TimeTracker
      */
     protected function getTimeTracker()
     {
-        return $GLOBALS['TT'];
+        return GeneralUtility::makeInstance(TimeTracker::class);
     }
 
     /**
index e1dee92..82eb149 100644 (file)
@@ -55,8 +55,10 @@ class EidRequestHandler implements RequestHandlerInterface
     {
         // Starting time tracking
         $configuredCookieName = trim($GLOBALS['TYPO3_CONF_VARS']['BE']['cookieName']) ?: 'be_typo_user';
-        $GLOBALS['TT'] = new TimeTracker($request->getCookieParams()[$configuredCookieName] ? true : false);
-        $GLOBALS['TT']->start();
+
+        /** @var TimeTracker $timeTracker */
+        $timeTracker = GeneralUtility::makeInstance(TimeTracker::class, ($request->getCookieParams()[$configuredCookieName] ? true : false));
+        $timeTracker->start();
 
         // Hook to preprocess the current request
         if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/index_ts.php']['preprocessRequest'])) {
index 2b0ae0c..5e0dfeb 100644 (file)
@@ -333,13 +333,9 @@ class RequestHandler implements RequestHandlerInterface
     protected function initializeTimeTracker()
     {
         $configuredCookieName = trim($GLOBALS['TYPO3_CONF_VARS']['BE']['cookieName']) ?: 'be_typo_user';
-        $this->timeTracker = new TimeTracker($this->request->getCookieParams()[$configuredCookieName] ? true : false);
 
-        // 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;
+        /** @var TimeTracker timeTracker */
+        $this->timeTracker = GeneralUtility::makeInstance(TimeTracker::class, ($this->request->getCookieParams()[$configuredCookieName] ? true : false));
         $this->timeTracker->start();
     }
 
index 44e0d39..b6f2cbe 100644 (file)
@@ -171,7 +171,7 @@ class PageGenerator
         $tsfe = $GLOBALS['TSFE'];
 
         /** @var TimeTracker $timeTracker */
-        $timeTracker = $GLOBALS['TT'];
+        $timeTracker = GeneralUtility::makeInstance(TimeTracker::class);
 
         // PAGE CONTENT
         $timeTracker->incStackPointer();
@@ -206,7 +206,7 @@ class PageGenerator
         $tsfe = $GLOBALS['TSFE'];
 
         /** @var TimeTracker $timeTracker */
-        $timeTracker = $GLOBALS['TT'];
+        $timeTracker = GeneralUtility::makeInstance(TimeTracker::class);
 
         $pageRenderer = static::getPageRenderer();
         if ($tsfe->config['config']['moveJsFromHeaderToFooter']) {
index 980e37c..63a3008 100755 (executable)
@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Frontend\View;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Imaging\IconFactory;
+use TYPO3\CMS\Core\TimeTracker\TimeTracker;
 use TYPO3\CMS\Core\Type\Bitmask\Permission;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -777,10 +778,10 @@ class AdminPanelView
     }
 
     /**
-     * @return \TYPO3\CMS\Core\TimeTracker\TimeTracker
+     * @return TimeTracker
      */
     protected function getTimeTracker()
     {
-        return $GLOBALS['TT'];
+        return GeneralUtility::makeInstance(TimeTracker::class);
     }
 }
index 4b58c04..3bb4b89 100755 (executable)
@@ -106,7 +106,6 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         $this->typoScriptFrontendControllerMock->csConvObj = new CharsetConverter();
         $this->typoScriptFrontendControllerMock->renderCharset = 'utf-8';
         $GLOBALS['TSFE'] = $this->typoScriptFrontendControllerMock;
-        $GLOBALS['TT'] = new TimeTracker(false);
         $GLOBALS['TYPO3_DB'] = $this->getMock(\TYPO3\CMS\Core\Database\DatabaseConnection::class, array());
 
         $this->subject = $this->getAccessibleMock(
index d8e1cdb..869d945 100644 (file)
@@ -85,7 +85,7 @@ class TypoScriptFrontendControllerTest extends \TYPO3\CMS\Core\Tests\UnitTestCas
         $tsfe->content = file_get_contents(__DIR__ . '/Fixtures/renderedPage.html');
         $tsfe->config['INTincScript_ext']['divKey'] = '679b52796e75d474ccbbed486b6837ab';
         $tsfe->config['INTincScript'] = array('INT_SCRIPT.679b52796e75d474ccbbed486b6837ab' => array());
-        $GLOBALS['TT'] = new TimeTracker(false);
+
         return $tsfe;
     }
 
index ca4bad0..d0f9df3 100755 (executable)
@@ -16,6 +16,7 @@ namespace TYPO3\CMS\IndexedSearch\Controller;
 
 use TYPO3\CMS\Core\Charset\CharsetConverter;
 use TYPO3\CMS\Core\Html\HtmlParser;
+use TYPO3\CMS\Core\TimeTracker\TimeTracker;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
 use TYPO3\CMS\IndexedSearch\Utility;
@@ -172,6 +173,11 @@ class SearchFormController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin
     public $lexerObj;
 
     /**
+     * @var TimeTracker
+     */
+    protected $timeTracker;
+
+    /**
      * @var CharsetConverter
      */
     protected $charsetConverter;
@@ -213,6 +219,7 @@ class SearchFormController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin
         $this->indexerConfig = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['indexed_search']);
         $this->enableMetaphoneSearch = (bool)$this->indexerConfig['enableMetaphoneSearch'];
         $this->storeMetaphoneInfoAsWords = !\TYPO3\CMS\IndexedSearch\Utility\IndexedSearchUtility::isTableUsed('index_words');
+        $this->timeTracker = GeneralUtility::makeInstance(TimeTracker::class);
         // Initialize external document parsers for icon display and other soft operations
         if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['indexed_search']['external_parsers'])) {
             foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['indexed_search']['external_parsers'] as $extension => $_objRef) {
@@ -538,13 +545,13 @@ class SearchFormController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin
     public function getResultRows($searchWordArray, $freeIndexUid = -1)
     {
         // Getting SQL result pointer. This fetches ALL results (1,000,000 if found)
-        $GLOBALS['TT']->push('Searching result');
+        $this->timeTracker->push('Searching result');
         if ($hookObj = &$this->hookRequest('getResultRows_SQLpointer')) {
             $res = $hookObj->getResultRows_SQLpointer($searchWordArray, $freeIndexUid);
         } else {
             $res = $this->getResultRows_SQLpointer($searchWordArray, $freeIndexUid);
         }
-        $GLOBALS['TT']->pull();
+        $this->timeTracker->pull();
         // Organize and process result:
         $result = false;
         if ($res) {
@@ -642,9 +649,9 @@ class SearchFormController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin
         // Perform SQL Search / collection of result rows array:
         if ($list) {
             // Do the search:
-            $GLOBALS['TT']->push('execFinalQuery');
+            $this->timeTracker->push('execFinalQuery');
             $res = $this->execFinalQuery($list, $freeIndexUid);
-            $GLOBALS['TT']->pull();
+            $this->timeTracker->pull();
             return $res;
         } else {
             return false;
@@ -664,7 +671,7 @@ class SearchFormController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin
         $content = '';
         // Perform display of result rows array:
         if ($resData) {
-            $GLOBALS['TT']->push('Display Final result');
+            $this->timeTracker->push('Display Final result');
             // Set first selected row (for calculation of ranking later)
             $this->firstRow = $resData['firstRow'];
             // Result display here:
@@ -684,7 +691,7 @@ class SearchFormController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin
             } else {
                 $content = '<p' . $this->pi_classParam('noresults') . '>' . $this->pi_getLL('noResults', '', true) . '</p>';
             }
-            $GLOBALS['TT']->pull();
+            $this->timeTracker->pull();
         } else {
             $content .= '<p' . $this->pi_classParam('noresults') . '>' . $this->pi_getLL('noResults', '', true) . '</p>';
         }
@@ -814,7 +821,7 @@ class SearchFormController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin
                 // If there are spaces in the search-word, make a full text search instead.
                 $theType = 20;
             }
-            $GLOBALS['TT']->push('SearchWord "' . $sWord . '" - $theType=' . $theType);
+            $this->timeTracker->push('SearchWord "' . $sWord . '" - $theType=' . $theType);
             // Perform search for word:
             switch ($theType) {
                 case '1':
@@ -877,7 +884,7 @@ class SearchFormController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin
                     $totalHashList = $phashList;
                 }
             }
-            $GLOBALS['TT']->pull();
+            $this->timeTracker->pull();
             $c++;
         }
         return implode(',', $totalHashList);
index 8b25fe1..676ff9c 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\IndexedSearch\Domain\Repository;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\TimeTracker\TimeTracker;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
 use TYPO3\CMS\IndexedSearch\Indexer;
@@ -944,10 +945,10 @@ class IndexSearchRepository
     }
 
     /**
-     * @return \TYPO3\CMS\Core\TimeTracker\TimeTracker
+     * @return TimeTracker
      */
     protected function getTimeTracker()
     {
-        return $GLOBALS['TT'];
+        return GeneralUtility::makeInstance(TimeTracker::class);
     }
 }
index 01cc19a..c82bd6f 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\IndexedSearch;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\TimeTracker\TimeTracker;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
@@ -228,6 +229,19 @@ class Indexer
     public $flagBitMask;
 
     /**
+     * @var TimeTracker
+     */
+    protected $timeTracker;
+
+    /**
+     * Indexer constructor.
+     */
+    public function __construct()
+    {
+        $this->timeTracker = GeneralUtility::makeInstance(TimeTracker::class);
+    }
+
+    /**
      * Parent Object (TSFE) Initialization
      *
      * @param TypoScriptFrontendController $pObj Parent Object, passed by reference
@@ -2088,9 +2102,7 @@ class Indexer
      */
     public function log_push($msg, $key)
     {
-        if (is_object($GLOBALS['TT'])) {
-            $GLOBALS['TT']->push($msg, $key);
-        }
+        $this->timeTracker->push($msg, $key);
     }
 
     /**
@@ -2100,9 +2112,7 @@ class Indexer
      */
     public function log_pull()
     {
-        if (is_object($GLOBALS['TT'])) {
-            $GLOBALS['TT']->pull();
-        }
+        $this->timeTracker->pull();
     }
 
     /**
@@ -2114,9 +2124,7 @@ class Indexer
      */
     public function log_setTSlogMessage($msg, $errorNum = 0)
     {
-        if (is_object($GLOBALS['TT'])) {
-            $GLOBALS['TT']->setTSlogMessage($msg, $errorNum);
-        }
+        $this->timeTracker->setTSlogMessage($msg, $errorNum);
         $this->internal_log[] = $msg;
     }
 
index b101b3e..668145e 100644 (file)
@@ -13,6 +13,8 @@ namespace TYPO3\CMS\IndexedSearchMysql\Hook;
  *
  * The TYPO3 project - inspiring people to share!
  */
+use TYPO3\CMS\Core\TimeTracker\TimeTracker;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
  * Class that hooks into Indexed Search and replaces standard SQL queries with MySQL fulltext index queries.
@@ -43,10 +45,12 @@ class MysqlFulltextIndexHook
         // Perform SQL Search / collection of result rows array:
         $resource = false;
         if ($searchData) {
+            /** @var TimeTracker $timeTracker */
+            $timeTracker = GeneralUtility::makeInstance(TimeTracker::class);
             // Do the search:
-            $GLOBALS['TT']->push('execFinalQuery');
+            $timeTracker->push('execFinalQuery');
             $resource = $this->execFinalQuery_fulltext($searchData, $freeIndexUid);
-            $GLOBALS['TT']->pull();
+            $timeTracker->pull();
         }
         return $resource;
     }
index ac6b280..f68c202 100644 (file)
@@ -13,6 +13,8 @@ namespace TYPO3\CMS\Saltedpasswords;
  *
  * The TYPO3 project - inspiring people to share!
  */
+use TYPO3\CMS\Core\TimeTracker\TimeTracker;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
  * Class implements salted-password hashes authentication service.
@@ -192,7 +194,7 @@ class SaltedPasswordService extends \TYPO3\CMS\Sv\AbstractAuthenticationService
                     $this->authInfo['REMOTE_HOST'],
                     $this->login['uname']
                 ));
-                \TYPO3\CMS\Core\Utility\GeneralUtility::sysLog(sprintf($errorMessage, $this->authInfo['REMOTE_ADDR'], $this->authInfo['REMOTE_HOST'], $this->login['uname']), 'core', \TYPO3\CMS\Core\Utility\GeneralUtility::SYSLOG_SEVERITY_INFO);
+                GeneralUtility::sysLog(sprintf($errorMessage, $this->authInfo['REMOTE_ADDR'], $this->authInfo['REMOTE_HOST'], $this->login['uname']), 'core', GeneralUtility::SYSLOG_SEVERITY_INFO);
             } elseif ($validPasswd && $user['lockToDomain'] && strcasecmp($user['lockToDomain'], $this->authInfo['HTTP_HOST'])) {
                 // Lock domain didn't match, so error:
                 $errorMessage = 'Login-attempt from %s (%s), username \'%s\', locked domain \'%s\' did not match \'%s\'!';
@@ -204,7 +206,7 @@ class SaltedPasswordService extends \TYPO3\CMS\Sv\AbstractAuthenticationService
                     $user['lockToDomain'],
                     $this->authInfo['HTTP_HOST']
                 ));
-                \TYPO3\CMS\Core\Utility\GeneralUtility::sysLog(sprintf($errorMessage, $this->authInfo['REMOTE_ADDR'], $this->authInfo['REMOTE_HOST'], $user[$this->db_user['username_column']], $user['lockToDomain'], $this->authInfo['HTTP_HOST']), 'core', \TYPO3\CMS\Core\Utility\GeneralUtility::SYSLOG_SEVERITY_INFO);
+                GeneralUtility::sysLog(sprintf($errorMessage, $this->authInfo['REMOTE_ADDR'], $this->authInfo['REMOTE_HOST'], $user[$this->db_user['username_column']], $user['lockToDomain'], $this->authInfo['HTTP_HOST']), 'core', GeneralUtility::SYSLOG_SEVERITY_INFO);
                 $OK = 0;
             } elseif ($validPasswd) {
                 $this->writeLogMessage(TYPO3_MODE . ' Authentication successful for username \'%s\'', $this->login['uname']);
@@ -224,7 +226,7 @@ class SaltedPasswordService extends \TYPO3\CMS\Sv\AbstractAuthenticationService
     protected function updatePassword($uid, $updateFields)
     {
         $GLOBALS['TYPO3_DB']->exec_UPDATEquery($this->pObj->user_table, sprintf('uid = %u', $uid), $updateFields);
-        \TYPO3\CMS\Core\Utility\GeneralUtility::devLog(sprintf('Automatic password update for user record in %s with uid %u', $this->pObj->user_table, $uid), $this->extKey, 1);
+        GeneralUtility::devLog(sprintf('Automatic password update for user record in %s with uid %u', $this->pObj->user_table, $uid), $this->extKey, 1);
     }
 
     /**
@@ -248,12 +250,14 @@ class SaltedPasswordService extends \TYPO3\CMS\Sv\AbstractAuthenticationService
             $message = vsprintf($message, $params);
         }
         if (TYPO3_MODE === 'BE') {
-            \TYPO3\CMS\Core\Utility\GeneralUtility::sysLog($message, $this->extKey, \TYPO3\CMS\Core\Utility\GeneralUtility::SYSLOG_SEVERITY_NOTICE);
+            GeneralUtility::sysLog($message, $this->extKey, GeneralUtility::SYSLOG_SEVERITY_NOTICE);
         } else {
-            $GLOBALS['TT']->setTSlogMessage($message);
+            /** @var TimeTracker $timeTracker */
+            $timeTracker = GeneralUtility::makeInstance(TimeTracker::class);
+            $timeTracker->setTSlogMessage($message);
         }
         if (TYPO3_DLOG) {
-            \TYPO3\CMS\Core\Utility\GeneralUtility::devLog($message, $this->extKey, \TYPO3\CMS\Core\Utility\GeneralUtility::SYSLOG_SEVERITY_NOTICE);
+            GeneralUtility::devLog($message, $this->extKey, GeneralUtility::SYSLOG_SEVERITY_NOTICE);
         }
     }
 }