diff --git a/NEWS b/NEWS index bc6f12e479c..2a0c854e3b0 100644 --- a/NEWS +++ b/NEWS @@ -37,6 +37,10 @@ PHP NEWS - Standard: . Unserializing the uppercase 'S' tag is now deprecated. (timwolla) +- Streams: + . Implemented GH-15155 (Stream context is lost when custom stream wrapper is + being filtered). (Quentin Dreyer) + 01 Aug 2024, PHP 8.4.0alpha4 - GMP: diff --git a/ext/standard/php_fopen_wrapper.c b/ext/standard/php_fopen_wrapper.c index a5581d9cccb..ea33ba49043 100644 --- a/ext/standard/php_fopen_wrapper.c +++ b/ext/standard/php_fopen_wrapper.c @@ -352,7 +352,7 @@ static php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const c return NULL; } - if (!(stream = php_stream_open_wrapper(p + 10, mode, options, opened_path))) { + if (!(stream = php_stream_open_wrapper_ex(p + 10, mode, options, opened_path, context))) { efree(pathdup); return NULL; } diff --git a/ext/standard/tests/streams/gh15155.phpt b/ext/standard/tests/streams/gh15155.phpt new file mode 100644 index 00000000000..66953c85a29 --- /dev/null +++ b/ext/standard/tests/streams/gh15155.phpt @@ -0,0 +1,37 @@ +--TEST-- +GH-15155: Stream context is lost when custom stream wrapper is being filtered +--FILE-- +context); + var_dump($options['dummy']['foo']); + return true; + } + + public function stream_stat() + { + } + + public function stream_read() + { + } + + public function stream_eof() + { + } +} + +$context = stream_context_create(['dummy' => ['foo' => 'bar']]); +stream_wrapper_register('dummy', DummyWrapper::class); +file_get_contents('dummy://foo', false, $context); +@file_get_contents('php://filter/resource=dummy://foo', false, $context); +?> +--EXPECT-- +string(3) "bar" +string(3) "bar"