ID:               48870
 User updated by:  lorenz dot werner at michel-consulting dot de
 Reported By:      lorenz dot werner at michel-consulting dot de
 Status:           Closed
 Bug Type:         Unknown/Other Function
 Operating System: gentoo
 PHP Version:      5.2.10
 New Comment:

Thank you for your fast and competent feedback.


Previous Comments:
------------------------------------------------------------------------

[2009-07-09 16:42:09] il...@php.net

This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.



------------------------------------------------------------------------

[2009-07-09 15:15:18] lorenz dot werner at michel-consulting dot de

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 this bug report at http://bugs.php.net/?id=48870&edit=1

Reply via email to