Bug #62507 [NEW]: $_SERVER['REQUEST_TIME'] under mod_php5 returns miliseconds instead of seconds
| From: | theultramage at gmail dot com | Date: | Sun, 08 Jul 2012 13:30:07 +0000 |
| Subject: | Bug #62507 [NEW]: $_SERVER['REQUEST_TIME'] under mod_php5 returns miliseconds instead of seconds | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-171797@lists.php.net to get a copy of this message | ||
From: theultramage at gmail dot com
Operating system:
PHP version: 5.4.4
Package: Apache2 related
Bug Type: Bug
Bug description:$_SERVER['REQUEST_TIME'] under mod_php5 returns miliseconds instead of
seconds
Description:
------------
http://git.php.net/?p=php-src.git;a=commitdiff;h=f89effd2a83de2b1d6381f9b9403a8328e0998b6
On 6.nov.2010 Ilia Alshanetsky "Updated _SERVER['REQUEST_TIME'] to include
microsecond precision". This introduced a breaking change - since then
variable returns miliseconds instead of seconds.
http://git.php.net/?p=php-src.git;a=commitdiff;h=86c44e119fd71eeed6f3bc213d544a06cc4a13e5
On 23.jun.2011 someone finally noticed, and he "Fixed a bug with
calculation of REQUEST_TIME in apache2". However, he only fixed
apache2handler and omitted apache2filter.
The bug breaks existing code that uses $_SERVER['REQUEST_TIME'] in
timestamp comparisons and assumes that its value is in seconds. I tested
the attached patch and it fixes the issue (hopefully not introducing other
issues).
PS: $_SERVER['REQUEST_TIME_FLOAT'] is also affected.
Test script:
---------------
<?php
$rt = $_SERVER['REQUEST_TIME'];
$now = time();
echo $rt."\n";
echo $now."\n";
echo ( strlen((string)$rt) == strlen((string)$now) ) ? "OK" : "Error!";
?>
Expected result:
----------------
1341752154
1341752154
OK
Actual result:
--------------
CLI/CGI:
1341752154
1341752154
OK
MOD_PHP5:
1341752154539
1341752154
Error!
--
Edit bug report at https://bugs.php.net/bug.php?id=62507&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=62507&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=62507&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=62507&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=62507&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=62507&r=needdocs
Fixed in release: https://bugs.php.net/fix.php?id=62507&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=62507&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=62507&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=62507&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=62507&r=support
Expected behavior: https://bugs.php.net/fix.php?id=62507&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=62507&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=62507&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=62507&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=62507&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=62507&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=62507&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=62507&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=62507&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=62507&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=62507&r=mysqlcfg