Fixed bug #11267: Use PHP5 version of function microtime()
authorOliver Hader <oliver.hader@typo3.org>
Sun, 19 Jul 2009 13:58:53 +0000 (13:58 +0000)
committerOliver Hader <oliver.hader@typo3.org>
Sun, 19 Jul 2009 13:58:53 +0000 (13:58 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@5726 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_div.php
t3lib/class.t3lib_timetrack.php
typo3/sysext/cms/tslib/class.tslib_fe.php
typo3/sysext/cms/tslib/index_ts.php
typo3/sysext/install/mod/class.tx_install.php

index 4aa9171..63aa31d 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2009-07-19  Oliver Hader  <oliver@typo3.org>
 
        * Fixed bug #6875: IRRE - Sorting of child records is inverted on moving parent record to different page (thanks to Nabil Saleh)
+       * Fixed bug #11267: Use PHP5 version of function microtime()
 
 2009-07-18  Steffen Kamper  <info@sk-typo3.de>
 
index 073f686..8bc8240 100644 (file)
@@ -3865,15 +3865,12 @@ final class t3lib_div {
        }
 
        /**
-        * milliseconds
-        * microtime recalculated to t3lib_div::milliseconds(1/1000 sec)
-        * Usage: 20
+        * Gets the unixtime as milliseconds.
         *
-        * @return      integer
+        * @return      integer         The unixtime as milliseconds 
         */
-       public static function milliseconds()   {
-               $p=explode(' ',microtime());
-               return round(($p[0]+$p[1])*1000);
+       public static function milliseconds() {
+               return round(microtime(true) * 1000);
        }
 
        /**
index 5520704..d8a7742 100644 (file)
@@ -149,8 +149,7 @@ class t3lib_timeTrack {
                        3 => '<img src="'.TYPO3_mainDir.'gfx/icon_fatalerror.gif" width="18" height="16" align="absmiddle" alt="" />'
                );
 
-               $this->starttime = 0;
-               $this->starttime = $this->mtime();
+               $this->starttime = $this->getMilliseconds();
        }
 
        /**
@@ -174,7 +173,7 @@ class t3lib_timeTrack {
                        'level' => $this->tsStackLevel,
                        'tsStack' => $this->tsStack,
                        'value' => $value,
-                       'starttime' => microtime(),
+                       'starttime' => microtime(true),
                        'stackPointer' => $this->tsStackPointer
                );
        }
@@ -188,7 +187,7 @@ class t3lib_timeTrack {
         */
        function pull($content='')  {
                $k = end($this->currentHashPointer);
-               $this->tsStackLog[$k]['endtime'] =  microtime();
+               $this->tsStackLog[$k]['endtime'] =  microtime(true);
                $this->tsStackLog[$k]['content'] = $content;
 
                $this->tsStackLevel--;
@@ -258,9 +257,10 @@ class t3lib_timeTrack {
         * Returns the current time in milliseconds
         *
         * @return      integer
+        * @deprecated  since TYPO3 4.3 - use getDifferenceToStarttime() instead
         */
-       function mtime()    {
-               return $this->convertMicrotime(microtime())-$this->starttime;
+       function mtime() {
+               return $this->getDifferenceToStarttime();
        }
 
        /**
@@ -268,12 +268,38 @@ class t3lib_timeTrack {
         *
         * @param       string          PHP microtime string
         * @return      integer
+        * @deprecated  since TYPO3 4.3 - use getMilliseconds() instead that expects microtime as float instead of a string
         */
-       function convertMicrotime($microtime)   {
+       function convertMicrotime($microtime) {
+               t3lib_div::logDeprecatedFunction();
+
                $parts = explode(' ',$microtime);
                return round(($parts[0]+$parts[1])*1000);
        }
 
+       /**
+        * Gets a microtime value as milliseconds value.
+        *
+        * @param       float           $microtime: The microtime value - if not set the current time is used
+        * @return      integer         The microtime value as milliseconds value
+        */
+       public function getMilliseconds($microtime = NULL) {
+               if (!isset($microtime)) {
+                       $microtime = microtime(true);
+               }
+               return round($microtime * 1000);
+       }
+
+       /**
+        * Gets the difference between a given microtime value and the starting time as milliseconds.
+        *
+        * @param       float           $microtime: The microtime value - if not set the current time is used
+        * @return      integer         The difference between a given microtime value and starting time as milliseconds
+        */
+       public function getDifferenceToStarttime($microtime = NULL) {
+               return ($this->getMilliseconds($microtime) - $this->starttime);
+       }
+
 
 
 
@@ -305,8 +331,8 @@ class t3lib_timeTrack {
        function printTSlog() {
                        // Calculate times and keys for the tsStackLog
                foreach ($this->tsStackLog as $uniqueId => &$data) {
-                       $data['endtime'] = $this->convertMicrotime($data['endtime']) - $this->starttime;
-                       $data['starttime'] = $this->convertMicrotime($data['starttime']) - $this->starttime;
+                       $data['endtime'] = $this->getDifferenceToStarttime($data['endtime']);
+                       $data['starttime'] = $this->getDifferenceToStarttime($data['starttime']);
                        $data['deltatime'] = $data['endtime'] - $data['starttime'];
                        $data['key'] = implode($data['stackPointer'] ? '.' : '/', end($data['tsStack']));
                }
index c467aa4..ccdbaa3 100644 (file)
@@ -3465,9 +3465,9 @@ if (version == "n3") {
         */
        function setParseTime() {
                        // Compensates for the time consumed with Back end user initialization.
-               $this->scriptParseTime = $GLOBALS['TT']->convertMicrotime($GLOBALS['TYPO3_MISC']['microtime_end'])
-                                                               - $GLOBALS['TT']->convertMicrotime($GLOBALS['TYPO3_MISC']['microtime_start'])
-                                                               - ($GLOBALS['TT']->convertMicrotime($GLOBALS['TYPO3_MISC']['microtime_BE_USER_end'])-$GLOBALS['TT']->convertMicrotime($GLOBALS['TYPO3_MISC']['microtime_BE_USER_start']));
+               $this->scriptParseTime = $GLOBALS['TT']->getMilliseconds($GLOBALS['TYPO3_MISC']['microtime_end'])
+                                                               - $GLOBALS['TT']->getMilliseconds($GLOBALS['TYPO3_MISC']['microtime_start'])
+                                                               - ($GLOBALS['TT']->getMilliseconds($GLOBALS['TYPO3_MISC']['microtime_BE_USER_end']) - $GLOBALS['TT']->getMilliseconds($GLOBALS['TYPO3_MISC']['microtime_BE_USER_start']));
        }
 
        /**
index abeb3fd..77d68c9 100644 (file)
@@ -52,7 +52,7 @@ error_reporting (E_ALL ^ E_NOTICE);
 // ******************
 // Constants defined
 // ******************
-$TYPO3_MISC['microtime_start'] = microtime();
+$TYPO3_MISC['microtime_start'] = microtime(true);
 define('TYPO3_OS', stristr(PHP_OS,'win')&&!stristr(PHP_OS,'darwin')?'WIN':'');
 define('TYPO3_MODE','FE');
 
@@ -246,7 +246,7 @@ if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/index_ts.php']['preBeUser']))
 // *********
 $BE_USER='';
 if ($_COOKIE['be_typo_user']) {                // If the backend cookie is set, we proceed and checks if a backend user is logged in.
-       $TYPO3_MISC['microtime_BE_USER_start'] = microtime();
+       $TYPO3_MISC['microtime_BE_USER_start'] = microtime(true);
        $TT->push('Back End user initialized','');
 
                        // the value this->formfield_status is set to empty in order to disable login-attempts to the backend account through this script
@@ -265,7 +265,7 @@ if ($_COOKIE['be_typo_user']) {             // If the backend cookie is set, we proceed and
                        $TSFE->beUserLogin=0;
                }
        $TT->pull();
-       $TYPO3_MISC['microtime_BE_USER_end'] = microtime();
+       $TYPO3_MISC['microtime_BE_USER_end'] = microtime(true);
 } elseif ($TSFE->ADMCMD_preview_BEUSER_uid)    {
 
                // the value this->formfield_status is set to empty in order to disable login-attempts to the backend account through this script
@@ -490,7 +490,7 @@ $TSFE->storeSessionData();
 // ***********
 // Statistics
 // ***********
-$TYPO3_MISC['microtime_end'] = microtime();
+$TYPO3_MISC['microtime_end'] = microtime(true);
 $TSFE->setParseTime();
 if ($TSFE->isOutputting() && ($TSFE->TYPO3_CONF_VARS['FE']['debug'] || $TSFE->config['config']['debug']))      {
        echo '
index d33b155..4a5198e 100755 (executable)
@@ -2743,7 +2743,7 @@ From sub-directory:
 
 
                $this->messageFunc_nl2br=0;
-               $parseStart = microtime();
+               $parseStart = t3lib_div::milliseconds();
                $imageProc = t3lib_div::makeInstance('t3lib_stdGraphic');
                $imageProc->init();
                $imageProc->tempPath = $this->typo3temp_path;
@@ -3122,8 +3122,7 @@ From sub-directory:
                                ");
                        }
 
-                       $parseStop = microtime();
-                       $parseMS = t3lib_div::convertMicrotime($parseStop)-t3lib_div::convertMicrotime($parseStart);
+                       $parseMS = t3lib_div::milliseconds() - $parseStart;
                        $this->message('Info','Parsetime',$parseMS.' ms');
                }
                $this->output($this->outputWrapper($this->printAll()));