#27792 [Com]: [PATCH] Functions fail on large files (filesize,is_file,is_dir,readdir)

From: Date: Tue, 06 Jan 2009 12:12:55 +0000
Subject: #27792 [Com]: [PATCH] Functions fail on large files (filesize,is_file,is_dir,readdir)
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-132587@lists.php.net to get a copy of this message
ID: 27792 Comment by: hamdisahloul at hotmail dot com Reported By: kode at kodekrash dot com Status: Critical Bug Type: Filesystem function related Operating System: * (LFS) PHP Version: 5CVS, 6CVS (2008-08-11) New Comment: In Windows XP SP2 - Media Center Edition, PHP Version 5.2.1, both filesize() and filemtime() works great! But, under CENTOS Enterprise 5.2 i686 with PHP 5.2.8, both of the above functions fails. May be other functions also affected, like the following: fseek(), fwrite(), feof(), ...etc. As I can't write files to my system, larger that 2147483647 bytes Note that my file system can handle more huge files that that, though. Reproduce code: <?php $filepath = "/path/to/a/huge[more_than_2GB]/file.ext"; echo gmdate("d-M-Y h:i:s A", filemtime($filepath)) . "\r\n"; echo number_format(sprintf("%u", filesize($filepath)) / 1073741824, 2) . " GB\r\n"; ?> Expected result: X-Powered-By: PHP/5.2.8 Content-type: text/html 05-Jan-2009 05:55:53 PM 3.76 GB Actual result: X-Powered-By: PHP/5.2.8 Content-type: text/html <br /> <b>Warning</b>: filemtime() [<a href='function.filemtime'>function.filemtime</a>]: stat failed for /path/to/a/huge[more_than_2GB]/file.ext in <b>/path/to/file.php</b> on line <b>3</b><br /> 01-Jan-1970 12:00:00 AM <br /> <b>Warning</b>: filesize() [<a href='function.filesize'>function.filesize</a>]: stat failed for /path/to/a/huge[more_than_2GB]/file.ext in <b>/path/to/file.php</b> on line <b>4</b><br /> 0.00 GB Previous Comments: ------------------------------------------------------------------------ [2008-12-05 17:28:36] aklmnop at gmail dot com I had to change a couple more LVAL's to DVAL and RETURN_LONG to RETURN_DOUBLE after using the above patch, to make fseek(), fread(), ftell() and fwrite() work in PHP 5.2.4. This stuff is way too broken. Shamefully broken! ------------------------------------------------------------------------ [2008-03-22 22:20:51] xpuctu4 at abv dot bg php -v PHP 5.2.3-1ubuntu6.3 (cli) (built: Jan 10 2008 09:38:41) Copyright (c) 1997-2007 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies I do not know if the ubuntu version have any patches but my PHP works fine. I created a large file with dd if=/dev/urandom and this is my results: // print_r($foo) Array ( [size] => 4805357568 // filesize() [isfile] => 1 // is_file() [isreadable] => 1 // is_readable() [islink] => //is_link() empty maybe because it is not link ) // Now I read 1st 32 bytes // fopen(), fread(), fseek($filesize - 32), fread(), fclose() // strlen($data) 1st read: 32 bytes 2nd read: 32 bytes ------------------------------------------------------------------------ [2008-01-29 14:45:08] elevator at thebrainhotel dot com All indications are that this is *not* fixed in PHP 5.2.x, the one comment above notwithstanding. There's another conflicting comment re: PHP 5.2.x, and there's also a patch provided for PHP 5.3 -- if a patch is needed for PHP 5.3, it would certainly appear to *not* be fixed in PHP 5.2.x And then there's my personal experience with PHP 5.2.4 (from the Xampp distro for Windows), where I'm actually experiencing the problem when trying to use move_uploaded_file; likewise on 3 deployments of PHP 5.1.x I've tried ------------------------------------------------------------------------ [2008-01-18 12:01:27] radon8472 at hotmail dot com file_get_contents() has also Problems with files over 2 GB Border. Doea anybody know when there will be released an php version with lage File Support (4GB an larger) ? ------------------------------------------------------------------------ [2007-10-14 22:17:19] wez@php.net You might like to try the following patch: http://news.php.net/php.internals/32767 ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/27792 -- Edit this bug report at http://bugs.php.net/?id=27792&edit=1

« previous php.bugs (#132587) next »