FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Does this indicate a bug in PHP?
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Does this indicate a bug in PHP? [message #178908] Thu, 23 August 2012 23:36 Go to next message
Vlatko urlan is currently offline  Vlatko urlan
Messages: 2
Registered: May 2011
Karma: 0
Junior Member
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


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%)
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?

I've put the image up so that you can try with the exact same one: http://david.evorion.hr/img.jpg

--
Vlatko Šurlan
Re: Does this indicate a bug in PHP? [message #178913 is a reply to message #178908] Fri, 24 August 2012 22:47 Go to previous message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma: 0
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).
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Programming Rates
Next Topic: DOMDocument::saveHTML() Method Not Accepting Single Argument
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 28 11:31:05 GMT 2024

Total time taken to generate the page: 0.04227 seconds