1--TEST-- 2Bug #79984 (Stream filter is not called with closing arg) 3--FILE-- 4<?php 5 6class F extends php_user_filter 7{ 8 public function onCreate() 9 { 10 echo 'filter onCreate' . PHP_EOL; 11 return true; 12 } 13 14 public function onClose() 15 { 16 echo 'filter onClose' . PHP_EOL; 17 } 18 19 public function filter($in, $out, &$consumed, $closing) 20 { 21 while ($bucket = stream_bucket_make_writeable($in)) { 22 $bucket->data = strtoupper($bucket->data); 23 $consumed += $bucket->datalen; 24 stream_bucket_append($out, $bucket); 25 } 26 echo 'filtered ' . ($consumed ? $consumed : 0) . ' bytes'; 27 if ($closing) { 28 echo ' and closing.'; 29 } else { 30 echo '.'; 31 } 32 if (feof($this->stream)) { 33 echo ' Stream has reached end-of-file.'; 34 } 35 echo PHP_EOL; 36 return PSFS_PASS_ON; 37 } 38} 39 40stream_filter_register('f', 'F'); 41 42$str = str_repeat('a', 8320); 43 44$f2 = fopen('php://temp', 'r+b'); 45fwrite($f2, $str); 46fseek($f2, 0, SEEK_SET); 47stream_filter_append($f2, 'f', STREAM_FILTER_READ); 48var_dump(strlen(stream_get_contents($f2))); 49fclose($f2); 50 51?> 52--EXPECT-- 53filter onCreate 54filtered 8192 bytes. 55filtered 128 bytes and closing. Stream has reached end-of-file. 56int(8320) 57filter onClose 58