Merge branch 'PHP-5.6'

Conflicts:
	NEWS
	main/streams/filter.c
This commit is contained in:
Bob Weinand 2015-01-26 22:53:36 +01:00
commit 5845f2c0c1
2 changed files with 57 additions and 1 deletions

View 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)

View File

@ -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;