From:             m dot voelker at gmail dot com
Operating system: Linux
PHP version:      5.4.11
Package:          Testing related
Bug Type:         Bug
Bug description:Test lstat_stat_variation7 incorrectly fails on certain file 
systems

Description:
------------
This applies to PHP 5.4.11 as well as 5.3.21.

Test ext/standard/tests/file/lstat_stat_variation7.phpt may incorrectly
fail on delayed allocation file systems (in this case XFS on Linux).

Problem:
http://php.net/manual/en/function.stat.php
field 12 is "number of 512-byte blocks allocated"

The test does not fclose() the test file after writing to it, therefore
zero 512-byte blocks are allocated even though the file size is 45056
bytes.

Fix:
Change lstat_stat_variation7.phpt from

// writing to an empty file
echo "*** Testing stat() on file after data is written in it ***\n";
$fh = fopen($file_name,"w");
$old_stat = stat($file_name);
clearstatcache();
fwrite($fh, str_repeat((binary)"Hello World", $old_stat['blksize']));
$new_stat = stat($file_name);

to

// writing to an empty file
echo "*** Testing stat() on file after data is written in it ***\n";
$fh = fopen($file_name,"w");
$old_stat = stat($file_name);
clearstatcache();
fwrite($fh, str_repeat((binary)"Hello World", $old_stat['blksize']));
fclose($fh);
$new_stat = stat($file_name);

and the test succeeds.


Test script:
---------------
File: ext/standard/tests/file/lstat_stat_variation7.php

To confirm, modify $file_name = "$file_path/lstat_stat_variation7.tmp"; to
use a different file system and run
ext/standard/tests/file/lstat_stat_variation7.sh.


Expected result:
----------------
Build of PHP 5.4.11

Test executed on ext2:

*** Testing stat() on file after data is written in it ***
bool(true)
bool(true)
bool(true)

--- Done ---


Actual result:
--------------
Same test executed on XFS:

*** Testing stat() on file after data is written in it ***
bool(true)
bool(true)
Error: stat1 is not lesser than stat2 at key value: 12
Error: stat1 is not lesser than stat2 at key value: blocks

 Dumping stat array 1...
...

  ["size"]=>
  int(0)
...
  ["blocks"]=>
  int(0)

 Dumping stat array 2...
...
  ["size"]=>
  int(45056)
...
  ["blocks"]=>
  int(0)


-- 
Edit bug report at https://bugs.php.net/bug.php?id=64060&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=64060&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=64060&r=trysnapshot53
Try a snapshot (trunk):     
https://bugs.php.net/fix.php?id=64060&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=64060&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=64060&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=64060&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=64060&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=64060&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=64060&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=64060&r=notwrong
Not enough info:            
https://bugs.php.net/fix.php?id=64060&r=notenoughinfo
Submitted twice:            
https://bugs.php.net/fix.php?id=64060&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=64060&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64060&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=64060&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=64060&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=64060&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=64060&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=64060&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=64060&r=mysqlcfg

Reply via email to