#46164 [Opn->Csd]: stream_filter_remove() closes the stream
ID: 46164
Updated by: lbarnaud@php.net
Reported By: lbarnaud@php.net
-Status: Open
+Status: Closed
Bug Type: Streams related
Operating System: *
PHP Version: 5.3CVS-2008-09-24 (CVS)
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2008-09-28 23:03:25] ilia dot cheishvili at gmail dot com
This is caused by telling php_stream_filter_remove() to destruct the
stream when it is not necessary.
Here is the patch to fix it: http://pastebin.com/fabd37ae
And here is the test: http://pastebin.com/f42d8848c
------------------------------------------------------------------------
[2008-09-24 04:46:34] lbarnaud@php.net
Description:
------------
Calling stream_filter_remove() closes the stream when the filter is a
user filter.
Reproduce code:
---------------
class user_filter extends php_user_filter {
function filter($in, $out, &$consumed, $closing) {
while($bucket = stream_bucket_make_writeable($in)) {
$consumed += $bucket->datalen;
stream_bucket_append($out, $bucket);
}
return PSFS_PASS_ON;
}
}
stream_filter_register('user_filter','user_filter');
$fd = fopen('/tmp/test','w');
$filter = stream_filter_append($fd, 'user_filter');
stream_filter_remove($filter);
var_dump(fclose($fd));
Expected result:
----------------
bool(true)
Actual result:
--------------
Warning: fclose(): 5 is not a valid stream resource in /tmp/rep.php on
line 15
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=46164&edit=1
Thread (3 messages)