mirror of
https://github.com/php/php-src.git
synced 2024-11-24 02:15:04 +08:00
Merge branch 'PHP-5.6'
Conflicts: NEWS main/streams/filter.c
This commit is contained in:
commit
5845f2c0c1
56
ext/standard/tests/streams/stream_multi_filters_close.phpt
Normal file
56
ext/standard/tests/streams/stream_multi_filters_close.phpt
Normal file
@ -0,0 +1,56 @@
|
||||
--TEST--
|
||||
Check if multiple filters are closed correctly and never called again after close
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
class FirstFilter extends php_user_filter {
|
||||
public function filter($in, $out, &$consumed, $closing) {
|
||||
static $closed = 0;
|
||||
|
||||
while ($bucket = stream_bucket_make_writeable($in)) {
|
||||
stream_bucket_append($out, stream_bucket_new($this->stream, $bucket->data));
|
||||
}
|
||||
|
||||
if ($closing) {
|
||||
$closed++;
|
||||
}
|
||||
|
||||
if ($closed > 0) {
|
||||
var_dump($closed++);
|
||||
}
|
||||
return PSFS_PASS_ON;
|
||||
}
|
||||
}
|
||||
|
||||
class SecondFilter extends php_user_filter {
|
||||
public function filter($in, $out, &$consumed, $closing) {
|
||||
static $closed = 0;
|
||||
|
||||
while ($bucket = stream_bucket_make_writeable($in)) {
|
||||
stream_bucket_append($out, stream_bucket_new($this->stream, $bucket->data));
|
||||
}
|
||||
|
||||
if ($closing) {
|
||||
$closed++;
|
||||
}
|
||||
|
||||
if ($closed > 0) {
|
||||
var_dump($closed++);
|
||||
}
|
||||
return PSFS_PASS_ON;
|
||||
}
|
||||
}
|
||||
|
||||
$r = fopen("php://stdout", "w+");
|
||||
stream_filter_register("first", "FirstFilter");
|
||||
stream_filter_register("second", "SecondFilter");
|
||||
$first = stream_filter_prepend($r, "first", STREAM_FILTER_WRITE, []);
|
||||
$second = stream_filter_prepend($r, "second", STREAM_FILTER_WRITE, []);
|
||||
fwrite($r, "test\n");
|
||||
stream_filter_remove($second);
|
||||
stream_filter_remove($first);
|
||||
?>
|
||||
--EXPECT--
|
||||
test
|
||||
int(1)
|
||||
int(1)
|
@ -447,7 +447,7 @@ PHPAPI int _php_stream_filter_flush(php_stream_filter *filter, int finish)
|
||||
for(current = filter; current; current = current->next) {
|
||||
php_stream_filter_status_t status;
|
||||
|
||||
status = filter->fops->filter(stream, filter, inp, outp, NULL, flags);
|
||||
status = filter->fops->filter(stream, current, inp, outp, NULL, flags);
|
||||
if (status == PSFS_FEED_ME) {
|
||||
/* We've flushed the data far enough */
|
||||
return SUCCESS;
|
||||
|
Loading…
Reference in New Issue
Block a user