summaryrefslogtreecommitdiff
path: root/ext/libxml
diff options
context:
space:
mode:
Diffstat (limited to 'ext/libxml')
-rw-r--r--ext/libxml/libxml.c10
-rw-r--r--ext/libxml/tests/bug54440.phpt51
2 files changed, 55 insertions, 6 deletions
diff --git a/ext/libxml/libxml.c b/ext/libxml/libxml.c
index 7fcfafdc1..ea07e8878 100644
--- a/ext/libxml/libxml.c
+++ b/ext/libxml/libxml.c
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: libxml.c 306939 2011-01-01 02:19:59Z felipe $ */
+/* $Id: libxml.c 313665 2011-07-25 11:42:53Z felipe $ */
#define IS_EXT_MODULE
@@ -119,7 +119,7 @@ static const zend_function_entry libxml_functions[] = {
PHP_FE(libxml_clear_errors, arginfo_libxml_clear_errors)
PHP_FE(libxml_get_errors, arginfo_libxml_get_errors)
PHP_FE(libxml_disable_entity_loader, arginfo_libxml_disable_entity_loader)
- {NULL, NULL, NULL}
+ PHP_FE_END
};
zend_module_entry libxml_module_entry = {
@@ -222,6 +222,7 @@ static void php_libxml_node_free_list(xmlNodePtr node TSRMLS_DC)
switch (node->type) {
/* Skip property freeing for the following types */
case XML_NOTATION_NODE:
+ case XML_ENTITY_DECL:
break;
case XML_ENTITY_REF_NODE:
php_libxml_node_free_list((xmlNodePtr) node->properties TSRMLS_CC);
@@ -233,7 +234,6 @@ static void php_libxml_node_free_list(xmlNodePtr node TSRMLS_DC)
case XML_ATTRIBUTE_DECL:
case XML_DTD_NODE:
case XML_DOCUMENT_TYPE_NODE:
- case XML_ENTITY_DECL:
case XML_NAMESPACE_DECL:
case XML_TEXT_NODE:
php_libxml_node_free_list(node->children TSRMLS_CC);
@@ -310,9 +310,7 @@ 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());
- }
+ context = php_stream_context_from_zval(LIBXML(stream_context), 0);
ret_val = php_stream_open_wrapper_ex(path_to_open, (char *)mode, ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL, context);
if (isescaped) {
diff --git a/ext/libxml/tests/bug54440.phpt b/ext/libxml/tests/bug54440.phpt
new file mode 100644
index 000000000..4074ff9fe
--- /dev/null
+++ b/ext/libxml/tests/bug54440.phpt
@@ -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
+ )
+
+)