--- embedaddon/php/ext/simplexml/simplexml.c 2012/05/29 12:34:42 1.1.1.2 +++ embedaddon/php/ext/simplexml/simplexml.c 2014/06/15 20:03:55 1.1.1.5 @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2012 The PHP Group | + | Copyright (c) 1997-2014 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: simplexml.c,v 1.1.1.2 2012/05/29 12:34:42 misho Exp $ */ +/* $Id: simplexml.c,v 1.1.1.5 2014/06/15 20:03:55 misho Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -1070,7 +1070,7 @@ static HashTable * sxe_get_prop_hash(zval *object, int int namelen; int test; char use_iter; - zval *iter_data; + zval *iter_data = NULL; use_iter = 0; @@ -1081,15 +1081,9 @@ static HashTable * sxe_get_prop_hash(zval *object, int zend_hash_init(rv, 0, NULL, ZVAL_PTR_DTOR, 0); } else if (sxe->properties) { - if (GC_G(gc_active)) { - return sxe->properties; - } zend_hash_clean(sxe->properties); rv = sxe->properties; } else { - if (GC_G(gc_active)) { - return NULL; - } ALLOC_HASHTABLE(rv); zend_hash_init(rv, 0, NULL, ZVAL_PTR_DTOR, 0); sxe->properties = rv; @@ -1135,7 +1129,7 @@ static HashTable * sxe_get_prop_hash(zval *object, int node = NULL; } else if (sxe->iter.type != SXE_ITER_CHILD) { - if ( !node->children || !node->parent || node->children->next || node->children->children || node->parent->children == node->parent->last ) { + if ( !node->children || !node->parent || !node->next || node->children->next || node->children->children || node->parent->children == node->parent->last ) { node = node->children; } else { iter_data = sxe->iter.data; @@ -1201,6 +1195,16 @@ next_iter: } /* }}} */ +static HashTable * sxe_get_gc(zval *object, zval ***table, int *n TSRMLS_DC) /* {{{ */ { + php_sxe_object *sxe; + sxe = php_sxe_fetch_object(object TSRMLS_CC); + + *table = NULL; + *n = 0; + return sxe->properties; +} +/* }}} */ + static HashTable * sxe_get_properties(zval *object TSRMLS_DC) /* {{{ */ { return sxe_get_prop_hash(object, 0 TSRMLS_CC); @@ -1265,6 +1269,9 @@ SXE_METHOD(xpath) } if (!sxe->node) { php_libxml_increment_node_ptr((php_libxml_node_object *)sxe, xmlDocGetRootElement((xmlDocPtr) sxe->document->ptr), NULL TSRMLS_CC); + if (!sxe->node) { + RETURN_FALSE; + } } nodeptr = php_sxe_get_first_node(sxe, sxe->node->node TSRMLS_CC); @@ -1417,7 +1424,11 @@ SXE_METHOD(asXML) xmlNodeDumpOutput(outbuf, (xmlDocPtr) sxe->document->ptr, node, 0, 0, ((xmlDocPtr) sxe->document->ptr)->encoding); xmlOutputBufferFlush(outbuf); +#ifdef LIBXML2_NEW_BUFFER + RETVAL_STRINGL((char *)xmlOutputBufferGetContent(outbuf), xmlOutputBufferGetSize(outbuf), 1); +#else RETVAL_STRINGL((char *)outbuf->buffer->content, outbuf->buffer->use, 1); +#endif xmlOutputBufferClose(outbuf); } } else { @@ -1513,22 +1524,31 @@ static void sxe_add_registered_namespaces(php_sxe_obje } /* }}} */ -/* {{{ 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); - - sxe_add_registered_namespaces(sxe, xmlDocGetRootElement((xmlDocPtr)sxe->document->ptr), recursive, return_value TSRMLS_CC); + if(from_root){ + node = xmlDocGetRootElement((xmlDocPtr)sxe->document->ptr); + }else{ + GET_NODE(sxe, node); + } + + if (node == NULL) { + RETURN_FALSE; + } + + array_init(return_value); + sxe_add_registered_namespaces(sxe, node, recursive, return_value TSRMLS_CC); } /* }}} */ @@ -1956,7 +1976,9 @@ static zend_object_handlers sxe_object_handlers = { /* sxe_objects_compare, sxe_object_cast, sxe_count_elements, - sxe_get_debug_info + sxe_get_debug_info, + NULL, + sxe_get_gc }; /* }}} */ @@ -2518,6 +2540,11 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_simplexmlelement_getnam ZEND_ARG_INFO(0, recursve) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_simplexmlelement_getdocnamespaces, 0, 0, 0) + ZEND_ARG_INFO(0, recursve) + ZEND_ARG_INFO(0, from_root) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_simplexmlelement_children, 0, 0, 0) ZEND_ARG_INFO(0, ns) ZEND_ARG_INFO(0, is_prefix) @@ -2586,7 +2613,7 @@ static const zend_function_entry sxe_functions[] = { / SXE_ME(attributes, arginfo_simplexmlelement_children, ZEND_ACC_PUBLIC) SXE_ME(children, arginfo_simplexmlelement_children, ZEND_ACC_PUBLIC) SXE_ME(getNamespaces, arginfo_simplexmlelement_getnamespaces, ZEND_ACC_PUBLIC) - SXE_ME(getDocNamespaces, arginfo_simplexmlelement_getnamespaces, ZEND_ACC_PUBLIC) + SXE_ME(getDocNamespaces, arginfo_simplexmlelement_getdocnamespaces, ZEND_ACC_PUBLIC) SXE_ME(getName, arginfo_simplexmlelement__void, ZEND_ACC_PUBLIC) SXE_ME(addChild, arginfo_simplexmlelement_addchild, ZEND_ACC_PUBLIC) SXE_ME(addAttribute, arginfo_simplexmlelement_addchild, ZEND_ACC_PUBLIC) @@ -2638,7 +2665,7 @@ PHP_MINFO_FUNCTION(simplexml) { php_info_print_table_start(); php_info_print_table_header(2, "Simplexml support", "enabled"); - php_info_print_table_row(2, "Revision", "$Id: simplexml.c,v 1.1.1.2 2012/05/29 12:34:42 misho Exp $"); + php_info_print_table_row(2, "Revision", "$Id: simplexml.c,v 1.1.1.5 2014/06/15 20:03:55 misho Exp $"); php_info_print_table_row(2, "Schema support", #ifdef LIBXML_SCHEMAS_ENABLED "enabled");