]> granicus.if.org Git - php/commitdiff
Synch from HEAD
authorRob Richards <rrichards@php.net>
Wed, 17 May 2006 16:35:50 +0000 (16:35 +0000)
committerRob Richards <rrichards@php.net>
Wed, 17 May 2006 16:35:50 +0000 (16:35 +0000)
- Fix bug #37456 (DOMElement->setAttribute() loops forever)
- update iterators for engine change merged from HEAD

ext/dom/dom_iterators.c
ext/dom/php_dom.c

index aaf00d67c02f28626c95d386a24c19f8a3baac11..88a06e460e3e3f41f747264dffc64d3cf7680dc1 100644 (file)
@@ -162,7 +162,7 @@ static int php_dom_iterator_current_key(zend_object_iterator *iter, char **str_k
        object = (zval *)iterator->intern.data;
 
        if (instanceof_function(Z_OBJCE_P(object), dom_nodelist_class_entry TSRMLS_CC)) {
-               *int_key = iter->index - 1;
+               *int_key = iter->index;
                return HASH_KEY_IS_LONG;
        } else {
                curobj = iterator->curobj;
@@ -187,7 +187,7 @@ static void php_dom_iterator_move_forward(zend_object_iterator *iter TSRMLS_DC)
        dom_object *intern;
        dom_object *nnmap;
        dom_nnodemap_object *objmap;
-       int ret, previndex=1;
+       int ret, previndex=0;
        HashTable *nodeht;
        zval **entry;
 
@@ -228,9 +228,9 @@ static void php_dom_iterator_move_forward(zend_object_iterator *iter TSRMLS_DC)
                        }
                } else {
                        if (objmap->nodetype == XML_ENTITY_NODE) {
-                               curnode = php_dom_libxml_hash_iter(objmap->ht, iter->index - 1);
+                               curnode = php_dom_libxml_hash_iter(objmap->ht, iter->index);
                        } else {
-                               curnode = php_dom_libxml_notation_iter(objmap->ht, iter->index - 1);
+                               curnode = php_dom_libxml_notation_iter(objmap->ht, iter->index);
                        }
                }
        }
@@ -268,7 +268,7 @@ zend_object_iterator *php_dom_get_iterator(zend_class_entry *ce, zval *object, i
                zend_error(E_ERROR, "An iterator cannot be used with foreach by reference");
        }
        iterator = emalloc(sizeof(php_dom_iterator));
-       
+
        object->refcount++;
        iterator->intern.data = (void*)object;
        iterator->intern.funcs = &php_dom_iterator_funcs;
index fba049be93e08c726786f754c3316f5ab25cc1b5..73a604f136e9ba995be8bdcc1dd08a093a49db0e 100644 (file)
@@ -860,6 +860,8 @@ void node_list_unlink(xmlNodePtr node TSRMLS_DC)
                if (wrapper != NULL ) {
                        xmlUnlinkNode(node);
                } else {
+                       if (node->type == XML_ENTITY_REF_NODE)
+                               break;
                        node_list_unlink(node->children TSRMLS_CC);
 
                        switch (node->type) {