summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXinchen Hui <laruence@gmail.com>2016-09-30 16:01:19 +0800
committerXinchen Hui <laruence@gmail.com>2016-09-30 16:01:19 +0800
commit68da84875ef4dd1aa5dacf2ab43db5b88e30d1f7 (patch)
tree6f3be6227ad66d1cca0d4caf14636ab6a98be626
parentb28277db9444a737a904a1f8a8df26aaa184dad8 (diff)
parent98705148f003551c330ace7f702448333a789180 (diff)
downloadphp-git-68da84875ef4dd1aa5dacf2ab43db5b88e30d1f7.tar.gz
Merge branch 'PHP-7.1' of git.php.net:/php-src into PHP-7.1
* 'PHP-7.1' of git.php.net:/php-src: fix user filter bug
-rw-r--r--ext/standard/tests/streams/user_streams_consumed_bug.phpt32
-rw-r--r--ext/standard/user_filters.c2
2 files changed, 33 insertions, 1 deletions
diff --git a/ext/standard/tests/streams/user_streams_consumed_bug.phpt b/ext/standard/tests/streams/user_streams_consumed_bug.phpt
new file mode 100644
index 0000000000..147a7bd0a7
--- /dev/null
+++ b/ext/standard/tests/streams/user_streams_consumed_bug.phpt
@@ -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)
+
diff --git a/ext/standard/user_filters.c b/ext/standard/user_filters.c
index b31235b4f1..5ca6e0bb1f 100644
--- a/ext/standard/user_filters.c
+++ b/ext/standard/user_filters.c
@@ -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) {