[BUGFIX] Stabilize a flaky unit test 97/53297/2
authorChristian Kuhn <lolli@schwarzbu.ch>
Wed, 21 Jun 2017 11:09:22 +0000 (13:09 +0200)
committerJan Helke <typo3@helke.de>
Wed, 21 Jun 2017 11:29:27 +0000 (13:29 +0200)
getParseTimeReturnsZeroIfNoValuesAreSet() tends to fail sometimes
if $beUserInitialization is > 0 but $totalParseTime is 0. This
edge case of method getParseTime() is avoided by rearranging the call
order of $this->getMilliseconds() slightly.

Change-Id: If5cf00196f6739224c34011b0f8c1ef1f5bbb39a
Resolves: #81653
Related: #80742
Releases: master, 8.7
Reviewed-on: https://review.typo3.org/53297
Reviewed-by: Thomas Hohn <thomas@hohn.dk>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Anja Leichsenring <anja.leichsenring@typo3.com>
Tested-by: Anja Leichsenring <anja.leichsenring@typo3.com>
Reviewed-by: Jan Helke <typo3@helke.de>
Tested-by: Jan Helke <typo3@helke.de>
typo3/sysext/core/Classes/TimeTracker/TimeTracker.php

index 2af4cbf..6186efb 100644 (file)
@@ -303,13 +303,15 @@ class TimeTracker implements SingletonInterface
     public function getParseTime(): int
     {
         // Compensates for the time consumed with Back end user initialization.
-        $processStart = isset($GLOBALS['TYPO3_MISC']['microtime_start']) ? $GLOBALS['TYPO3_MISC']['microtime_start'] : null;
-        $processEnd = isset($GLOBALS['TYPO3_MISC']['microtime_end']) ? $GLOBALS['TYPO3_MISC']['microtime_end'] : null;
-        $totalParseTime = $this->getMilliseconds($processEnd) - $this->getMilliseconds($processStart);
+        $processStart = $this->getMilliseconds($GLOBALS['TYPO3_MISC']['microtime_start'] ?? null);
+
+        $beUserInitializationStart = $this->getMilliseconds($GLOBALS['TYPO3_MISC']['microtime_BE_USER_start'] ?? null);
+        $beUserInitializationEnd = $this->getMilliseconds($GLOBALS['TYPO3_MISC']['microtime_BE_USER_end'] ?? null);
+        $beUserInitialization = $beUserInitializationEnd - $beUserInitializationStart;
+
+        $processEnd = $this->getMilliseconds($GLOBALS['TYPO3_MISC']['microtime_end'] ?? null);
+        $totalParseTime = $processEnd - $processStart;
 
-        $beUserInitializationStart = isset($GLOBALS['TYPO3_MISC']['microtime_BE_USER_start']) ? $GLOBALS['TYPO3_MISC']['microtime_BE_USER_start'] : null;
-        $beUserInitializationEnd = isset($GLOBALS['TYPO3_MISC']['microtime_BE_USER_end']) ? $GLOBALS['TYPO3_MISC']['microtime_BE_USER_end'] : null;
-        $beUserInitialization = $this->getMilliseconds($beUserInitializationEnd) - $this->getMilliseconds($beUserInitializationStart);
         if ($beUserInitialization > 0) {
             $totalParseTime -= $beUserInitialization;
         }