Re: Does this indicate a bug in PHP? [message #178913 is a reply to message #178908] |
Fri, 24 August 2012 22:47 |
Thomas 'PointedEars'
Messages: 701 Registered: October 2010
Karma:
|
Senior Member |
|
|
Vlatko Ć urlan wrote:
> Pay attention to the different mtimes reported.
>
> vlatko@david:/tmp/mtimeTests$ php5 -v
> PHP 5.3.3-7+squeeze14 with Suhosin-Patch (cli) (built: Aug 6 2012
> 20:08:59) Copyright (c) 1997-2009 The PHP Group
> Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
> with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans
> with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH
>
> vlatko@david:/tmp/mtimeTests$ ll
> total 56
> -rw-r----- 1 vlatko vlatko 51946 Kol 23 19:01 img.jpg
`stat img.jpg', which shows the milliseconds, would have been more helpful
for diagnostics.
> vlatko@david:/tmp/mtimeTests$ php5 -r 'echo filemtime("img.jpg") . "\n";'
> ****1345741275****
>
> vlatko@david:/tmp/mtimeTests$ php5 -r '$zip = new ZipArchive();
> $zip->open("test.zip", ZIPARCHIVE::CREATE); $zip->addFile("img.jpg");
> $zip->close();'
>
> vlatko@david:/tmp/mtimeTests$ php5 -r '$zip = new ZipArchive();
> $zip->open("test.zip"); print_r($zip->statIndex(0));'
> [snip]
> [mtime] => ****1345741274****
> [snip]
>
> vlatko@david:/tmp/mtimeTests$ zip update test.zip
> adding: test.zip (stored 0%)
This adds test.zip to the ZIP archive `update.zip'. It has nothing to do
with the *mtime* of test.zip or the files in test.zip.
> vlatko@david:/tmp/mtimeTests$ php5 -r '$zip = new ZipArchive();
> $zip->open("test.zip"); print_r($zip->statIndex(0));'
> [snip]
> [mtime] => ****1345741274****
> [snip]
>
> I detected this while trying to update a ZIP archive using PHP. Obviously
> I tried to compare filemtime for each file with what ZipArchive reported
> and realized that they are never the same. What is going on here?
$ stat -c %Y test.txt
1270260799
$ php5 -r 'echo filemtime("test.txt") . "\n";'
1270260799
$ php5 -r '$zip = new ZipArchive(); $zip->open("test.zip",
ZIPARCHIVE::CREATE); $zip->addFile("test.txt"); $zip->close();'
$ php5 -r '$zip = new ZipArchive(); $zip->open("test.zip"); print_r($zip-
> statIndex(0));' | grep mtime
[mtime] => 1270260798
$ php5 --version
PHP 5.3.10-1 (cli) (built: Feb 3 2012 10:03:01)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
with XCache v1.3.2, Copyright (c) 2005-2011, by mOo
with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans
with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH
The mtime with ZipArchive is behind by only one second after epoch. This
might be caused by that mtime not taking into account UTC's leap seconds.
PointedEars
--
When all you know is jQuery, every problem looks $(olvable).
|
|
|