[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-cvs
Subject:    [PHP-CVS] cvs: php-src(PHP_5_1) /ext/simplexml simplexml.c  /ext/simplexml/tests 029.phpt
From:       "Marcus Boerger" <helly () php ! net>
Date:       2006-02-27 13:38:04
Message-ID: cvshelly1141047484 () cvsserver
[Download RAW message or body]

helly		Mon Feb 27 13:38:04 2006 UTC

  Added files:                 (Branch: PHP_5_1)
    /php-src/ext/simplexml/tests	029.phpt 

  Modified files:              
    /php-src/ext/simplexml	simplexml.c 
  Log:
  - MFH Fix count/foreach interaction
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/simplexml/simplexml.c?r1=1.151.2.14&r2=1.151.2.15&diff_format=u
                
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.151.2.14 \
                php-src/ext/simplexml/simplexml.c:1.151.2.15
--- php-src/ext/simplexml/simplexml.c:1.151.2.14	Mon Feb 27 11:55:18 2006
+++ php-src/ext/simplexml/simplexml.c	Mon Feb 27 13:38:03 2006
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: simplexml.c,v 1.151.2.14 2006/02/27 11:55:18 helly Exp $ */
+/* $Id: simplexml.c,v 1.151.2.15 2006/02/27 13:38:03 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)
@@ -1450,6 +1455,11 @@
 	}
 
 
+	if (sxe->iter.data) {
+		zval_ptr_dtor(&sxe->iter.data);
+	}
+	sxe->iter.data = data;
+
 	return SUCCESS;
 }
 /* }}} */
@@ -2103,7 +2113,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.14 $");
+	php_info_print_table_row(2, "Revision", "$Revision: 1.151.2.15 $");
 	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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic