cataphract Sat, 09 Apr 2011 18:32:55 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=310109
Log: - Fixed bug #54440: libxml extension ignores default context. Bug: http://bugs.php.net/54440 (Closed) libxml extension ignores default context Changed paths: U php/php-src/branches/PHP_5_3/NEWS U php/php-src/branches/PHP_5_3/ext/libxml/libxml.c A php/php-src/branches/PHP_5_3/ext/libxml/tests/bug54440.phpt U php/php-src/trunk/ext/libxml/libxml.c A php/php-src/trunk/ext/libxml/tests/bug54440.phpt Modified: php/php-src/branches/PHP_5_3/NEWS =================================================================== --- php/php-src/branches/PHP_5_3/NEWS 2011-04-09 16:59:36 UTC (rev 310108) +++ php/php-src/branches/PHP_5_3/NEWS 2011-04-09 18:32:55 UTC (rev 310109) @@ -41,6 +41,9 @@ . Fixed bug #53339 (Fails to build when compilng with gcc 4.5 and DSO libraries). (Clint Byrum, Raphael) +- libxml extension: + . Fixed bug #54440 (libxml extension ignores default context). (Gustavo) + - mbstring extension: . Fixed bug #54494 (mb_substr() mishandles UTF-32LE and UCS-2LE). (Gustavo) Modified: php/php-src/branches/PHP_5_3/ext/libxml/libxml.c =================================================================== --- php/php-src/branches/PHP_5_3/ext/libxml/libxml.c 2011-04-09 16:59:36 UTC (rev 310108) +++ php/php-src/branches/PHP_5_3/ext/libxml/libxml.c 2011-04-09 18:32:55 UTC (rev 310109) @@ -310,9 +310,7 @@ } } - 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) { Added: php/php-src/branches/PHP_5_3/ext/libxml/tests/bug54440.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/libxml/tests/bug54440.phpt (rev 0) +++ php/php-src/branches/PHP_5_3/ext/libxml/tests/bug54440.phpt 2011-04-09 18:32:55 UTC (rev 310109) @@ -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 + ) + +) Modified: php/php-src/trunk/ext/libxml/libxml.c =================================================================== --- php/php-src/trunk/ext/libxml/libxml.c 2011-04-09 16:59:36 UTC (rev 310108) +++ php/php-src/trunk/ext/libxml/libxml.c 2011-04-09 18:32:55 UTC (rev 310109) @@ -312,10 +312,8 @@ } } - 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); Added: php/php-src/trunk/ext/libxml/tests/bug54440.phpt =================================================================== --- php/php-src/trunk/ext/libxml/tests/bug54440.phpt (rev 0) +++ php/php-src/trunk/ext/libxml/tests/bug54440.phpt 2011-04-09 18:32:55 UTC (rev 310109) @@ -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 + ) + +)
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php