diff --git a/ext/standard/php_fopen_wrapper.c b/ext/standard/php_fopen_wrapper.c index a5581d9cccbe6..ea33ba4904346 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 0000000000000..66953c85a2929 --- /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"