Bug #52918 [Opn->Bgs]: fpassthru causes early script termination with no errors
| From: | cataphract@php.net | Date: | Fri, 24 Sep 2010 01:43:58 +0000 |
| Subject: | Bug #52918 [Opn->Bgs]: fpassthru causes early script termination with no errors | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-154603@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=52918&edit=1
ID: 52918
Updated by: cataphract@php.net
Reported by: ray at rainstormconsulting dot com
Summary: fpassthru causes early script termination with no
errors
-Status: Open
+Status: Bogus
Type: Bug
Package: Streams related
Operating System: CentOS 4.8
PHP Version: 5.2.14
Block user comment: N
New Comment:
This is expected behavior. See ignore_user_abort. Using buffering delays
sending the data, hence delaying the moment PHP is able to detect the
connection's been aborted.
Previous Comments:
------------------------------------------------------------------------
[2010-09-23 22:21:40] ray at rainstormconsulting dot com
Description:
------------
I am using PHP 5.2.14 built from source on CentOS 4.8. This also happens
in PHP
5.2.13.
Basically what is happening is that if I run the following code (from a
web
address, not CLI), and terminate before sleep() is done performing, I do
not see
the last error_log(). I only see the one before fpassthru(). This only
happens
when $content is very large (not sure how large, but my script was using
~15MB
string).
It appears that if I add ob_start() and ob_end_flush() around the
script,
everything performs correctly, even if I terminate the script early.
I have already verified that the content is in fact being written to
$file just
fine. I manually checked the file and also called file_get_contents()
after
file_put_contents() and the data came back just fine.
Again, I receive no errors in the PHP error log or Apache log (e.g. no
segfaults).
Test script:
---------------
// $content must be much larger than this sample...something like 15MB
of base64
// encoded data will do the trick.
$content = 'JVBERi0xLjQKJeTjz9IKNjMgMCBvYmoKPDwKL0xpbmVhcm';
file_put_contents($file, $content); // $file is a valid full file
path/name
$fp = fopen($file, 'r');
sleep(5); // This is only here to aid in terminating the script before
fpassthru() is called.
error_log('Error log before fpassthru() is called!');
$characterCount = fpassthru($fp);
error_log(var_export($characterCount, true));
Expected result:
----------------
I would expect fpassthru() to not totally kill the script. Even though
the client
will not see the contents of fpassthru(), the rest of the script should
still
perform as expected.
Actual result:
--------------
The script terminates before the last error_log is called and no errors
are
displayed, no segfaults reported, etc., even when the highest PHP error
logging is
enabled.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=52918&edit=1