|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2015-03-10 13:57 UTC] johnregphpbug at stefanie dot de
Description: ------------ (This is my first ever bug report on php.) (PHP 5.6.3 doesn't show up on the drop down list on the bug report form, so I choose "irrelevant".) I have Win 7, 64 bit. Latest XAMPP version, that has a 32 bit php 5.6.3. On testing http://php.net/manual/en/function.fseek.php#112647 for a very big file (bigger than PHP_MAX_INT 2147483647) I'm now pretty sure, that the consecutivly following fseeks are summed up before really executed on the filepointer. The result is that those fseeks only seek up to PHP_MAX_INT ahead from the current filepointer-position. I found a workaround for that, as putting a fread between two originally consecutivly following fseeks seems to stop the aggregation. (Though that workaround needs a second small workaround, as fread can't be called with 0 bytes read length, so I have to fread one byte and put this in the calculation for breaking up the big number seek to smaller seeks.) (Another bug: Once the filepointer is over PHP_MAX_INT then ftell will give back a negative number.) PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 05:00:02 2025 UTC |
I will try to install a 64 bit version. The manual is just not really clear at this. 1. The answers on I got on stackoverflow can't be entirly correct, and other people have come accross the restriction, too: 2. Reading over the PHP_MAX_INT treshhold is possible. But the workaround found at least in one user-comment on the manual of fseek and another old bugreport that shows a workaround for the workaround don't work as expected. I'm very sure there is a bug in that php-version. Of course it might really just be undocumented behaviour outside the defintions. (But then it should throw an error; which it doesn't.) (Can I just download a 64 bit build from the snapshots and put in my xampp installation instead of old php version?) If you find time, you might want to test the workaround I tried: <?php $testdata = ''; // C:\xampp\todrivei\germany-latest.osm 42.651.795.559 , 42651795559 file size from last year $filenameandpath = 'C:\xampp\todrivei\germany-latest.osm'; $seekto = 42651795559 - 2000;; // PHP_INT_MAX: 2147483647; function my_fseek($fp,$pos,$first=0) { if($first) fseek($fp,0,SEEK_SET); $pos=floatval($pos); // within limits, use normal fseek if($pos<=PHP_INT_MAX) { fseek($fp,$pos,SEEK_CUR); } // out of limits, use recursive fseek else { fseek($fp,PHP_INT_MAX,SEEK_CUR); $pos -= PHP_INT_MAX; $tempchar = fread($fp,1); // ."\n\r"; $pos -= 1; my_fseek($fp,$pos); } } $testdata = 'PHP_INT_MAX: '.PHP_INT_MAX."\n\r"; $testdata .= 'seekto: ' . $seekto."\n\r"; $handle = fopen($filenameandpath,'r'); my_fseek($handle, floatval($seekto),1); $testdata .= fread($handle,62000); fclose($handle); echo $testdata; ?> I can even try to seek over the file size (like I set seekto to 400GByte) and fread still returns data of the file.