ID:          46164
 Comment by:  ilia dot cheishvili at gmail dot com
 Reported By: [EMAIL PROTECTED]
 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] [EMAIL PROTECTED]

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

Reply via email to