From: lorenz dot werner at michel-consulting dot de Operating system: gentoo PHP version: 5.2.10 PHP Bug Type: Unknown/Other Function Bug description: File is missing 2048 bytes after fclose. When script ends the file is complete
Description: ------------ Since I upgraded to PHP 5.2.10 I have got an problem with files not beiing completly written. Exactly 2048 bytes are missing while the script is running. Even after fclose it is not completley written. If I open the file for reading again and then close it again the file is complete. But that can't be correct... or is it? Reproduce code: --------------- $fh = fopen($pdf_tarfile, "wb"); $ch = curl_init(PDF_SERVICE_URL); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_FILE, $fh); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); curl_exec($ch); $return_code = curl_errno($ch); if( $return_code ) { trigger_error('curl returned error ' . $return_code . ': ' . curl_error($ch), E_USER_ERROR); return false; } curl_close($ch); fclose($fh); // It only works with this workaround { $fh = fopen($pdf_tarfile, "rb"); fclose($fh); } $cmd = 'tar' . ' -x' // extract . ' -f ' . escapeshellarg($pdf_tarfile) // this file . ' -C ' . escapeshellarg($path); // into this directory $stdout = array(); exec($cmd . ' 2>&1', $stdout, $return_code); if ($return_code) { trigger_error('tar returned error ' . $return_code . ': ' . implode("\n", $stdout), E_USER_ERROR); return false; } Expected result: ---------------- Correctly unpacked tar archive. Actual result: -------------- Tar fails to unpack the file because it is missing the last 2048 Bytes. If I run the command manually after the script is finished, the file can be unpacked without any problem at all. -- Edit bug report at http://bugs.php.net/?id=48870&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=48870&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=48870&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=48870&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=48870&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=48870&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=48870&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=48870&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=48870&r=needscript Try newer version: http://bugs.php.net/fix.php?id=48870&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=48870&r=support Expected behavior: http://bugs.php.net/fix.php?id=48870&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=48870&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=48870&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=48870&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48870&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=48870&r=dst IIS Stability: http://bugs.php.net/fix.php?id=48870&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=48870&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=48870&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=48870&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=48870&r=mysqlcfg