Page MenuHomePhabricator

wfTimestamp can take excesive amounts of time for inputs very far in the past (aka around year 0)
Closed, ResolvedPublic

Description

I was testing some code related to getting time-stamps out if image files. I was trying it with various invalid inputs. One of them was if it had a time of 0000-00-00T00:00:00 (not correct, but not insane in terms of potential invalid input in the case of unknown timestamp) but a timezone of -06:00.

The code I had tried to convert that timestamp to utc (by subtracting 6*60*60 from the TS_UNIX representation). At one point it makes a wfTimestamp(TS_EXIF, -62170005600); call. This causes a "Fatal error: Maximum execution time of 30 seconds exceeded in /var/www/w/metadata/includes/GlobalFunctions.php on line 1925" error.

Doing a quick test from the command line I get:
$ time echo 'echo wfTimestamp(TS_EXIF, -62170005600)' | php eval.php
-0001:11:29 18:00:00

real 0m16.744s
user 0m16.609s
sys 0m0.064s

Admittedly, my code should probably check for special value of all 0's as a probable thing that could be in a file if the person didn't know the time. However at the same time, there really shouldn't be any value that could make the wfTimestamp function take 16 seconds.

For reference, the line causing the issue of wfTimestamp is:
$d = date_create( $strtime, new DateTimeZone( 'GMT' ) );


Version: unspecified
Severity: enhancement

Details

Reference
bz28127

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 11:25 PM
bzimport set Reference to bz28127.
bzimport added a subscriber: Unknown Object (MLST).

I'm pretty sure this is a dupe but I can't find the other bug right now.

Found it! Please check whether this is dupe of bug 14898.

Well if it's not that exactly, it's similar-looking and is also fixed in PHP 5.3.5 as I'm testing atm. :)

  • This bug has been marked as a duplicate of bug 14898 ***