Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #6837 > unrolled thread

Does this indicate a bug in PHP?

Started byVlatko Šurlan <vlatko.surlan@evorion.hr>
First post2012-08-24 01:36 +0200
Last post2012-08-25 00:47 +0200
Articles 2 — 2 participants

Back to article view | Back to comp.lang.php


Contents

  Does this indicate a bug in PHP? Vlatko Šurlan <vlatko.surlan@evorion.hr> - 2012-08-24 01:36 +0200
    Re: Does this indicate a bug in PHP? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-08-25 00:47 +0200

#6837 — Does this indicate a bug in PHP?

FromVlatko Šurlan <vlatko.surlan@evorion.hr>
Date2012-08-24 01:36 +0200
SubjectDoes this indicate a bug in PHP?
Message-ID<20120824013610.b719e083.vlatko.surlan@evorion.hr>
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

[toc] | [next] | [standalone]


#6842

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2012-08-25 00:47 +0200
Message-ID<1968307.IDv9frP7EL@PointedEars.de>
In reply to#6837
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).

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web