#46164 [Com]: stream_filter_remove() closes the stream
| From: | ilia dot cheishvili at gmail dot com | Date: | Sun, 28 Sep 2008 23:03:26 +0000 |
| Subject: | #46164 [Com]: stream_filter_remove() closes the stream | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-129311@lists.php.net to get a copy of this message | ||
ID: 46164
Comment by: ilia dot cheishvili at gmail dot com
Reported By: lbarnaud@php.net
Status: Open
Bug Type: Streams related
PHP Version: 5.3CVS-2008-09-24 (CVS)
New Comment:
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
Previous Comments:
------------------------------------------------------------------------
[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