|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-11-27 20:56 UTC] den at nurfuerspam dot de
[2021-07-28 10:26 UTC] cmb@php.net
-Status: Open
+Status: Duplicate
-Assigned To:
+Assigned To: cmb
[2021-07-28 10:26 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 17:00:01 2025 UTC |
Description: ------------ When a custom stream filter applied to a phar archive then "closing" flag is not set during the call to the php_user_filter::filter($in, $out, &$consumed, $closing) So, user filter can not terminate filtration correctly and typically returns PSFS_FEED_ME to read more data to process after eof and this results into empty string from the filter. When executing stream_get_meta_data($this->stream) inside filter() method I can see that eof flag for stream is already set, but "closing" flag is set to false: array(9) { ["wrapper_type"]=> string(3) "PHP" ["stream_type"]=> string(11) "phar stream" ["mode"]=> string(2) "rb" ["unread_bytes"]=> int(0) ["seekable"]=> bool(true) ["uri"]=> string(53) "php://filter/read=test/resource=phar://test.phar/Test" ["timed_out"]=> bool(false) ["blocked"]=> bool(true) ["eof"]=> bool(true) } Test script: --------------- <?php // Require phar.readonly = Off in php.ini class PharStreamFilter extends php_user_filter { protected $data = ''; public function filter($in, $out, &$consumed, $closing){ while ($bucket = stream_bucket_make_writeable($in)) { $this->data .= $bucket->data; } if ($closing) { $consumed += strlen($this->data); $bucket = stream_bucket_new($this->stream, $this->data); stream_bucket_append($out, $bucket); return PSFS_PASS_ON; } return PSFS_FEED_ME; } } stream_filter_register('test', 'PharStreamFilter'); $source = 'Test'; $phar = new Phar('test.phar'); $phar['Test'] = $source; $actual = file_get_contents('php://filter/read=test/resource=phar://test.phar/Test'); echo ($actual==$source) ? 'OK' : 'FAIL'; Expected result: ---------------- I'm expecting that filter will receive "closing" flag correctly and all data will be returned from the filter correctly. So output should be: OK Actual result: -------------- Filter doesn't receive "closing" flag for phar stream and returns an empty string. Output will be: FAIL