From: kraghuba at in dot ibm dot com Operating system: Windows XP, RHEL 5 PHP version: 5CVS-2007-07-22 (snap) PHP Bug Type: Filesystem function related Bug description: file pointer not changed when file truncated with append mode
Description: ------------ The file pointer position is not changed when a file opened in append mode is truncated using ftruncate() function. As per the documentation of ftruncate() function, the file pointer should be changed. http://in2.php.net/manual/en/function.ftruncate.php from doumentation: ... Note: The file pointer is changed only in append mode. In write mode, additional fseek() call is needed. ... This is applicable to php5 as well as php6. checked it on WinXP and RHEL 5. Reproduce code: --------------- <?php $fp = fopen("test.txt", "w"); fwrite($fp, "testing ftrucate function with append mode"); fclose($fp); var_dump( filesize("test.txt") ); $fp = fopen ("test.txt", "a"); var_dump( ftell($fp) ); var_dump( ftruncate($fp, 10) ); var_dump( ftell($fp) ); fclose($fp); clearstatcache(); var_dump( filesize("test.txt") ); ?> Expected result: ---------------- int(42) int(0) bool(true) int(10) int(10) Actual result: -------------- int(42) int(0) bool(true) int(0) int(10) -- Edit bug report at http://bugs.php.net/?id=42066&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=42066&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=42066&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=42066&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=42066&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=42066&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=42066&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=42066&r=needscript Try newer version: http://bugs.php.net/fix.php?id=42066&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=42066&r=support Expected behavior: http://bugs.php.net/fix.php?id=42066&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=42066&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=42066&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=42066&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=42066&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=42066&r=dst IIS Stability: http://bugs.php.net/fix.php?id=42066&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=42066&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=42066&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=42066&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=42066&r=mysqlcfg