diff --git a/ext/dom/dom_iterators.c b/ext/dom/dom_iterators.c index ae752229e40..3b422ed556f 100644 --- a/ext/dom/dom_iterators.c +++ b/ext/dom/dom_iterators.c @@ -62,7 +62,7 @@ xmlNodePtr create_notation(const xmlChar *name, const xmlChar *ExternalID, const } /* }}} */ -xmlNode *php_dom_libxml_hash_iter(xmlHashTable *ht, int index) /* {{{ */ +static xmlNode *php_dom_libxml_hash_iter_ex(xmlHashTable *ht, int index) { int htsize; @@ -77,17 +77,18 @@ xmlNode *php_dom_libxml_hash_iter(xmlHashTable *ht, int index) /* {{{ */ return NULL; } } -/* }}} */ -xmlNode *php_dom_libxml_notation_iter(xmlHashTable *ht, int index) /* {{{ */ +xmlNode *php_dom_libxml_hash_iter(dom_nnodemap_object *objmap, int index) { - xmlNotation *notation = (xmlNotation *) php_dom_libxml_hash_iter(ht, index); - if (notation != NULL) { - return create_notation(notation->name, notation->PublicID, notation->SystemID); + xmlNode *curnode = php_dom_libxml_hash_iter_ex(objmap->ht, index); + + if (curnode != NULL && objmap->nodetype != XML_ENTITY_NODE) { + xmlNotation *notation = (xmlNotation *) curnode; + curnode = create_notation(notation->name, notation->PublicID, notation->SystemID); } - return NULL; + + return curnode; } -/* }}} */ static void php_dom_iterator_dtor(zend_object_iterator *iter) /* {{{ */ { @@ -194,11 +195,7 @@ static void php_dom_iterator_move_forward(zend_object_iterator *iter) /* {{{ */ } } } else { - if (objmap->nodetype == XML_ENTITY_NODE) { - curnode = php_dom_libxml_hash_iter(objmap->ht, iter->index); - } else { - curnode = php_dom_libxml_notation_iter(objmap->ht, iter->index); - } + curnode = php_dom_libxml_hash_iter(objmap, iter->index); } } @@ -279,11 +276,7 @@ zend_object_iterator *php_dom_get_iterator(zend_class_entry *ce, zval *object, i } } } else { - if (objmap->nodetype == XML_ENTITY_NODE) { - curnode = php_dom_libxml_hash_iter(objmap->ht, 0); - } else { - curnode = php_dom_libxml_notation_iter(objmap->ht, 0); - } + curnode = php_dom_libxml_hash_iter(objmap, 0); } } err: diff --git a/ext/dom/namednodemap.c b/ext/dom/namednodemap.c index 5a76815d46f..1fca749372f 100644 --- a/ext/dom/namednodemap.c +++ b/ext/dom/namednodemap.c @@ -139,11 +139,7 @@ xmlNodePtr php_dom_named_node_map_get_item(dom_nnodemap_object *objmap, zend_lon if ((objmap->nodetype == XML_NOTATION_NODE) || objmap->nodetype == XML_ENTITY_NODE) { if (objmap->ht) { - if (objmap->nodetype == XML_ENTITY_NODE) { - itemnode = php_dom_libxml_hash_iter(objmap->ht, index); - } else { - itemnode = php_dom_libxml_notation_iter(objmap->ht, index); - } + itemnode = php_dom_libxml_hash_iter(objmap, index); } } else { xmlNodePtr nodep = dom_object_get_node(objmap->baseobj); diff --git a/ext/dom/nodelist.c b/ext/dom/nodelist.c index a01fd159480..a178b110dc7 100644 --- a/ext/dom/nodelist.c +++ b/ext/dom/nodelist.c @@ -142,11 +142,7 @@ void php_dom_nodelist_get_item_into_zval(dom_nnodemap_object *objmap, zend_long if (index >= 0) { if (objmap != NULL) { if (objmap->ht) { - if (objmap->nodetype == XML_ENTITY_NODE) { - itemnode = php_dom_libxml_hash_iter(objmap->ht, index); - } else { - itemnode = php_dom_libxml_notation_iter(objmap->ht, index); - } + itemnode = php_dom_libxml_hash_iter(objmap, index); } else { if (objmap->nodetype == DOM_NODESET) { HashTable *nodeht = HASH_OF(&objmap->baseobj_zv); diff --git a/ext/dom/php_dom.h b/ext/dom/php_dom.h index 1b214d11544..9a5bdcbe663 100644 --- a/ext/dom/php_dom.h +++ b/ext/dom/php_dom.h @@ -151,8 +151,7 @@ bool dom_node_children_valid(xmlNodePtr node); void php_dom_create_iterator(zval *return_value, dom_iterator_type iterator_type, bool modern); void dom_namednode_iter(dom_object *basenode, int ntype, dom_object *intern, xmlHashTablePtr ht, const char *local, size_t local_len, const char *ns, size_t ns_len); xmlNodePtr create_notation(const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID); -xmlNode *php_dom_libxml_hash_iter(xmlHashTable *ht, int index); -xmlNode *php_dom_libxml_notation_iter(xmlHashTable *ht, int index); +xmlNode *php_dom_libxml_hash_iter(dom_nnodemap_object *objmap, int index); zend_object_iterator *php_dom_get_iterator(zend_class_entry *ce, zval *object, int by_ref); void dom_set_doc_classmap(php_libxml_ref_obj *document, zend_class_entry *basece, zend_class_entry *ce); xmlNodePtr php_dom_create_fake_namespace_decl(xmlNodePtr nodep, xmlNsPtr original, zval *return_value, dom_object *parent_intern);