Patch add_optional_param_to_getDocNamespaces for SimpleXML related Bug #55218
Patch version 2011-07-23 03:14 UTC
Return to Bug #55218 |
Download this patch
Patch Revisions:
Developer: lonnyk@gmail.com
Index: ext/simplexml/simplexml.c
===================================================================
--- ext/simplexml/simplexml.c (revision 313617)
+++ ext/simplexml/simplexml.c (working copy)
@@ -1514,22 +1514,28 @@
}
/* }}} */
-/* {{{ proto string SimpleXMLElement::getDocNamespaces([bool recursive])
+/* {{{ proto string SimpleXMLElement::getDocNamespaces([bool recursive [, bool from_root])
Return all namespaces registered with document */
SXE_METHOD(getDocNamespaces)
{
- zend_bool recursive = 0;
+ zend_bool recursive = 0, from_root = 1;
php_sxe_object *sxe;
+ xmlNodePtr node;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &recursive) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|bb", &recursive, &from_root) == FAILURE) {
return;
}
array_init(return_value);
sxe = php_sxe_fetch_object(getThis() TSRMLS_CC);
+ if(from_root){
+ node = xmlDocGetRootElement((xmlDocPtr)sxe->document->ptr);
+ }else{
+ GET_NODE(sxe, node);
+ }
- sxe_add_registered_namespaces(sxe, xmlDocGetRootElement((xmlDocPtr)sxe->document->ptr), recursive, return_value TSRMLS_CC);
+ sxe_add_registered_namespaces(sxe, node, recursive, return_value TSRMLS_CC);
}
/* }}} */
@@ -2661,3 +2667,4 @@
* vim600: fdm=marker
* vim: noet sw=4 ts=4
*/
+
|