|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits              [2009-07-09 16:42 UTC] iliaa@php.net
  [2009-07-09 18:43 UTC] lorenz dot werner at michel-consulting dot de
 | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 12:00:01 2025 UTC | 
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.