mirror of
https://github.com/php/php-src.git
synced 2025-08-21 01:45:16 +02:00
fix user filter bug
This commit is contained in:
parent
581e890483
commit
a8d031fbd8
2 changed files with 33 additions and 1 deletions
32
ext/standard/tests/streams/user_streams_consumed_bug.phpt
Normal file
32
ext/standard/tests/streams/user_streams_consumed_bug.phpt
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
--TEST--
|
||||||
|
Testing user filter on streams
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
class Intercept extends php_user_filter
|
||||||
|
{
|
||||||
|
public static $cache = '';
|
||||||
|
public function filter($in, $out, &$consumed, $closing)
|
||||||
|
{
|
||||||
|
while ($bucket = stream_bucket_make_writeable($in)) {
|
||||||
|
self::$cache .= $bucket->data;
|
||||||
|
$consumed += $bucket->datalen;
|
||||||
|
stream_bucket_append($out, $bucket);
|
||||||
|
}
|
||||||
|
return PSFS_PASS_ON;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$out = fwrite(STDOUT, "Hello\n");
|
||||||
|
var_dump($out);
|
||||||
|
|
||||||
|
stream_filter_register("intercept_filter", "Intercept");
|
||||||
|
stream_filter_append(STDOUT, "intercept_filter");
|
||||||
|
|
||||||
|
$out = fwrite(STDOUT, "Goodbye\n");
|
||||||
|
var_dump($out);
|
||||||
|
--EXPECTF--
|
||||||
|
Hello
|
||||||
|
int(6)
|
||||||
|
Goodbye
|
||||||
|
int(8)
|
||||||
|
|
|
@ -217,7 +217,7 @@ php_stream_filter_status_t userfilter_filter(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bytes_consumed) {
|
if (bytes_consumed) {
|
||||||
*bytes_consumed = Z_LVAL_P(&args[2]);
|
*bytes_consumed = zval_get_long(&args[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buckets_in->head) {
|
if (buckets_in->head) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue