mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Fix GH-15155: Keep stream context in filtered streams
Closes GH-15156
This commit is contained in:
parent
af8ef4c5b0
commit
7b32a145d9
3 changed files with 42 additions and 1 deletions
4
NEWS
4
NEWS
|
@ -37,6 +37,10 @@ PHP NEWS
|
||||||
- Standard:
|
- Standard:
|
||||||
. Unserializing the uppercase 'S' tag is now deprecated. (timwolla)
|
. 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
|
01 Aug 2024, PHP 8.4.0alpha4
|
||||||
|
|
||||||
- GMP:
|
- GMP:
|
||||||
|
|
|
@ -352,7 +352,7 @@ static php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const c
|
||||||
return NULL;
|
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);
|
efree(pathdup);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
37
ext/standard/tests/streams/gh15155.phpt
Normal file
37
ext/standard/tests/streams/gh15155.phpt
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
--TEST--
|
||||||
|
GH-15155: Stream context is lost when custom stream wrapper is being filtered
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class DummyWrapper
|
||||||
|
{
|
||||||
|
public $context;
|
||||||
|
|
||||||
|
public function stream_open(string $path, string $mode, int $options, ?string &$opened_path): bool
|
||||||
|
{
|
||||||
|
$options = stream_context_get_options($this->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"
|
Loading…
Add table
Add a link
Reference in a new issue