helly           Mon Feb 27 13:32:25 2006 UTC

  Added files:                 
    /php-src/ext/simplexml/tests        029.phpt 

  Modified files:              
    /php-src/ext/simplexml      php_simplexml.h simplexml.c 
  Log:
  - Fix count/foreach interaction
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/simplexml/php_simplexml.h?r1=1.23&r2=1.24&diff_format=u
Index: php-src/ext/simplexml/php_simplexml.h
diff -u php-src/ext/simplexml/php_simplexml.h:1.23 
php-src/ext/simplexml/php_simplexml.h:1.24
--- php-src/ext/simplexml/php_simplexml.h:1.23  Sun Feb 26 15:48:28 2006
+++ php-src/ext/simplexml/php_simplexml.h       Mon Feb 27 13:32:25 2006
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_simplexml.h,v 1.23 2006/02/26 15:48:28 helly Exp $ */
+/* $Id: php_simplexml.h,v 1.24 2006/02/27 13:32:25 helly Exp $ */
 
 #ifndef PHP_SIMPLEXML_H
 #define PHP_SIMPLEXML_H
@@ -67,7 +67,6 @@
        HashTable *properties;
        xmlXPathContextPtr xpath;
        struct {
-               int                   itertype;
                char                  *name;
                char                  *nsprefix;
                SXE_ITER              type;
http://cvs.php.net/viewcvs.cgi/php-src/ext/simplexml/simplexml.c?r1=1.194&r2=1.195&diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.194 
php-src/ext/simplexml/simplexml.c:1.195
--- php-src/ext/simplexml/simplexml.c:1.194     Mon Feb 27 11:55:23 2006
+++ php-src/ext/simplexml/simplexml.c   Mon Feb 27 13:32:25 2006
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: simplexml.c,v 1.194 2006/02/27 11:55:23 helly Exp $ */
+/* $Id: simplexml.c,v 1.195 2006/02/27 13:32:25 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -1438,9 +1438,14 @@
 {
        php_sxe_object  *sxe;
        xmlNodePtr       node;
+       zval            *data;
 
        *count = 0;
        sxe = php_sxe_fetch_object(object TSRMLS_CC);
+
+       data = sxe->iter.data;
+       sxe->iter.data = NULL;
+
        node = php_sxe_reset_iterator(sxe, 0 TSRMLS_CC);
        
        while (node)
@@ -1449,6 +1454,10 @@
                node = php_sxe_iterator_fetch(sxe, node->next, 0 TSRMLS_CC);
        }
 
+       if (sxe->iter.data) {
+               zval_ptr_dtor(&sxe->iter.data);
+       }
+       sxe->iter.data = data;
 
        return SUCCESS;
 }
@@ -2117,7 +2126,7 @@
 {
        php_info_print_table_start();
        php_info_print_table_header(2, "Simplexml support", "enabled");
-       php_info_print_table_row(2, "Revision", "$Revision: 1.194 $");
+       php_info_print_table_row(2, "Revision", "$Revision: 1.195 $");
        php_info_print_table_row(2, "Schema support",
 #ifdef LIBXML_SCHEMAS_ENABLED
                "enabled");

http://cvs.php.net/viewcvs.cgi/php-src/ext/simplexml/tests/029.phpt?view=markup&rev=1.1
Index: php-src/ext/simplexml/tests/029.phpt
+++ php-src/ext/simplexml/tests/029.phpt
--TEST--
SimpleXML: foreach and count
--SKIPIF--
<?php if (!extension_loaded("simplexml")) print "skip"; ?>
--FILE--
<?php 
$xml =<<<EOF
<people>
  <person name="Joe"/>
  <person name="John">
    <children>
      <person name="Joe"/>
    </children>
  </person>
  <person name="Jane"/>
</people>
EOF;

$people = simplexml_load_string($xml);

foreach($people as $person)
{
        var_dump((string)$person['name']);
        var_dump(count($people));
        var_dump(count($person));
}

?>
===DONE===
--EXPECTF--
string(3) "Joe"
int(3)
int(0)
string(4) "John"
int(3)
int(1)
string(4) "Jane"
int(3)
int(0)
===DONE===
--UEXPECTF--
unicode(3) "Joe"
int(3)
int(0)
unicode(4) "John"
int(3)
int(1)
unicode(4) "Jane"
int(3)
int(0)
===DONE===

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

Reply via email to