rrichards               Mon Mar 26 20:14:58 2007 UTC

  Added files:                 (Branch: PHP_5_2)
    /php-src/ext/simplexml/tests        bug37386.phpt 

  Modified files:              
    /php-src/ext/simplexml      simplexml.c 
  Log:
  fix bug #37386 (autocreating element doesn't assign value to first node)
  all single SimpleXMLElements are addressable using offset 0
  use correct node for xpath context node
  add test
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.151.2.22.2.23&r2=1.151.2.22.2.24&diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.151.2.22.2.23 
php-src/ext/simplexml/simplexml.c:1.151.2.22.2.24
--- php-src/ext/simplexml/simplexml.c:1.151.2.22.2.23   Tue Feb 20 14:08:43 2007
+++ php-src/ext/simplexml/simplexml.c   Mon Mar 26 20:14:58 2007
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: simplexml.c,v 1.151.2.22.2.23 2007/02/20 14:08:43 tony2001 Exp $ */
+/* $Id: simplexml.c,v 1.151.2.22.2.24 2007/03/26 20:14:58 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -138,7 +138,14 @@
        long nodendx = 0;
        
        if (sxe->iter.type == SXE_ITER_NONE) {
-               return NULL;
+               if (offset == 0) {
+                       if (cnt) {
+                               *cnt = 0;
+                       }
+                       return node;
+               } else {
+                       return NULL;
+               }
        }
        while (node && nodendx <= offset) {
                SKIP_TEXT(node)
@@ -429,7 +436,7 @@
        int                             nodendx = 0;
        int             test = 0;
        int                             new_value = 0;
-       long            cnt;
+       long            cnt = 0;
        zval            tmp_zv, trim_zv, value_copy;
 
        if (!member) {
@@ -1122,9 +1129,11 @@
                php_libxml_increment_node_ptr((php_libxml_node_object *)sxe, 
xmlDocGetRootElement((xmlDocPtr) sxe->document->ptr), NULL TSRMLS_CC);
        }
 
-       sxe->xpath->node = sxe->node->node;
+       nodeptr = php_sxe_get_first_node(sxe, sxe->node->node TSRMLS_CC);
+
+       sxe->xpath->node = nodeptr;
 
-       ns = xmlGetNsList((xmlDocPtr) sxe->document->ptr, (xmlNodePtr) 
sxe->node->node);
+       ns = xmlGetNsList((xmlDocPtr) sxe->document->ptr, nodeptr);
        if (ns != NULL) {
                while (ns[nsnbr] != NULL) {
                        nsnbr++;
@@ -2359,7 +2368,7 @@
 {
        php_info_print_table_start();
        php_info_print_table_header(2, "Simplexml support", "enabled");
-       php_info_print_table_row(2, "Revision", "$Revision: 1.151.2.22.2.23 $");
+       php_info_print_table_row(2, "Revision", "$Revision: 1.151.2.22.2.24 $");
        php_info_print_table_row(2, "Schema support",
 #ifdef LIBXML_SCHEMAS_ENABLED
                "enabled");

http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/tests/bug37386.phpt?view=markup&rev=1.1
Index: php-src/ext/simplexml/tests/bug37386.phpt
+++ php-src/ext/simplexml/tests/bug37386.phpt

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to