fix user filter bug

This commit is contained in:
Joe Watkins 2016-09-30 07:21:01 +01:00
parent 581e890483
commit a8d031fbd8
2 changed files with 33 additions and 1 deletions

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

View File

@ -217,7 +217,7 @@ php_stream_filter_status_t userfilter_filter(
}
if (bytes_consumed) {
*bytes_consumed = Z_LVAL_P(&args[2]);
*bytes_consumed = zval_get_long(&args[2]);
}
if (buckets_in->head) {