php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73586 php_user_filter::$stream is not set to the stream the filter is working on.
Submitted: 2016-11-23 07:43 UTC Modified: 2016-11-23 23:48 UTC
From: sd at jobs dot ch Assigned: dmitry (profile)
Status: Closed Package: Streams related
PHP Version: 7.0.13 OS: Ubuntu
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: sd at jobs dot ch
New email:
PHP Version: OS:

 

 [2016-11-23 07:43 UTC] sd at jobs dot ch
Description:
------------
In a php_user_filter class the property $stream is not set to the current stream in PHP 7.0.13 (and 7.0.12, 7.0.8) while executing the method filter(). I tried the example script from
http://stackoverflow.com/questions/27103269/what-is-a-bucket-brigade

It does work in PHP 5.3.29.

Test script:
---------------
<?php
class append_filter extends php_user_filter {
    public $stream;
    function filter($in, $out, &$consumed, $closing) {
        while ($bucket = stream_bucket_make_writeable($in)) {
            $consumed += $bucket->datalen;
            stream_bucket_append($out, $bucket);
        }
        if ($closing) {
            $bucket = stream_bucket_new($this->stream, "FooBar \n");
            stream_bucket_append($out, $bucket);
        }
        return PSFS_PASS_ON;
    }
}
stream_filter_register("append", "append_filter");
$fin = fopen($argv[1], 'rb');
stream_filter_append($fin, 'append', STREAM_FILTER_READ);
stream_copy_to_stream($fin, fopen('out', 'wb'));


Expected result:
----------------
In PHP 5.3.29 the, on the command line given, input file is copied to the file 'out' and "FooBar \n" is append to the file 'out'.

Actual result:
--------------
In PHP 7 the given file is just copied (whit out append the string) and error messages like this are produced:

PHP Notice:  Undefined property: append_filter::$stream in test-filter.php on line 10
PHP Warning:  stream_bucket_new(): supplied argument is not a valid stream resource in test-filter.php on line 10
PHP Warning:  stream_bucket_append() expects parameter 2 to be object, boolean given in test-filter.php on line 11


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-11-23 23:48 UTC] cmb@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: dmitry
 [2016-11-23 23:48 UTC] cmb@php.net
According to `git bisect` this issue has been introduced with
commit 887189ca[1].

Dmitry, can you please have a look at this?

<http://git.php.net/?p=php-src.git;a=commit;h=887189ca>
 [2016-11-28 09:57 UTC] dmitry@php.net
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=9a9ad56af0f80c69d363e8cfabe412da798c497d
Log: Fixed bug #73586 (php_user_filter::$stream is not set to the stream the filter is working on).
 [2016-11-28 09:57 UTC] dmitry@php.net
-Status: Verified +Status: Closed
 [2016-11-30 23:13 UTC] davey@php.net
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=9a9ad56af0f80c69d363e8cfabe412da798c497d
Log: Fixed bug #73586 (php_user_filter::$stream is not set to the stream the filter is working on).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Oct 13 04:01:26 2024 UTC