mirror of
https://github.com/php/php-src.git
synced 2024-12-12 11:23:53 +08:00
- Fixed bug #54440: libxml extension ignores default context.
This commit is contained in:
parent
db01e840c2
commit
09b990f499
@ -312,10 +312,8 @@ static void *php_libxml_streams_IO_open_wrapper(const char *filename, const char
|
||||
}
|
||||
}
|
||||
|
||||
if (LIBXML(stream_context)) {
|
||||
context = zend_fetch_resource(&LIBXML(stream_context) TSRMLS_CC, -1, "Stream-Context", NULL, 1, php_le_stream_context(TSRMLS_C));
|
||||
}
|
||||
|
||||
context = php_stream_context_from_zval(LIBXML(stream_context), 0);
|
||||
|
||||
ret_val = php_stream_open_wrapper_ex(path_to_open, (char *)mode, REPORT_ERRORS, NULL, context);
|
||||
if (isescaped) {
|
||||
xmlFree(resolved_path);
|
||||
|
51
ext/libxml/tests/bug54440.phpt
Normal file
51
ext/libxml/tests/bug54440.phpt
Normal file
@ -0,0 +1,51 @@
|
||||
--TEST--
|
||||
Bug #54440: libxml extension ignores default context
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded('simplexml')) die('skip simplexml required for this test'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
class TestWrapper {
|
||||
|
||||
function stream_open($path, $mode, $options, &$opened_path)
|
||||
{
|
||||
if ($this->context)
|
||||
print_r(stream_context_get_options($this->context));
|
||||
return false;
|
||||
}
|
||||
|
||||
function url_stat($path, $flags)
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
stream_wrapper_register("test", "TestWrapper")
|
||||
or die("Failed to register protocol");
|
||||
|
||||
$ctx1 = stream_context_create(array('test'=>array('test'=>'test 1')));
|
||||
$ctx2 = stream_context_create(array('test'=>array('test'=>'test 2')));
|
||||
|
||||
stream_context_set_default(stream_context_get_options($ctx1));
|
||||
@simplexml_load_file('test://sdfsdf');
|
||||
|
||||
libxml_set_streams_context($ctx2);
|
||||
@simplexml_load_file('test://sdfsdf');
|
||||
--EXPECT--
|
||||
Array
|
||||
(
|
||||
[test] => Array
|
||||
(
|
||||
[test] => test 1
|
||||
)
|
||||
|
||||
)
|
||||
Array
|
||||
(
|
||||
[test] => Array
|
||||
(
|
||||
[test] => test 2
|
||||
)
|
||||
|
||||
)
|
Loading…
Reference in New Issue
Block a user