summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Richards <rrichards@php.net>2007-08-14 12:09:52 +0000
committerRob Richards <rrichards@php.net>2007-08-14 12:09:52 +0000
commit4d17d8c681baaf03c25bcfc3231fb298d5cf93b6 (patch)
treebb73d3db26c1cf925f0ea7cd8d3b4388b95c36e3
parent731671e76782e63d3ad063afef89d4aab34c2e53 (diff)
downloadphp-git-4d17d8c681baaf03c25bcfc3231fb298d5cf93b6.tar.gz
fix bug #42259 (SimpleXMLIterator loses ancestry)
add test
-rwxr-xr-xext/spl/spl_sxe.c3
-rw-r--r--ext/spl/tests/bug42259.phpt49
2 files changed, 50 insertions, 2 deletions
diff --git a/ext/spl/spl_sxe.c b/ext/spl/spl_sxe.c
index 6060616243..a2cb7ff913 100755
--- a/ext/spl/spl_sxe.c
+++ b/ext/spl/spl_sxe.c
@@ -142,8 +142,7 @@ SPL_METHOD(SimpleXMLIterator, getChildren)
if (!sxe->iter.data || sxe->iter.type == SXE_ITER_ATTRLIST) {
return; /* return NULL */
}
- return_value->type = IS_OBJECT;
- return_value->value.obj = zend_objects_store_clone_obj(sxe->iter.data TSRMLS_CC);
+ RETURN_ZVAL(sxe->iter.data, 1, 0);
}
/* {{{ proto int SimpleXMLIterator::count() U
diff --git a/ext/spl/tests/bug42259.phpt b/ext/spl/tests/bug42259.phpt
new file mode 100644
index 0000000000..22c8bc5d61
--- /dev/null
+++ b/ext/spl/tests/bug42259.phpt
@@ -0,0 +1,49 @@
+--TEST--
+Bug #42259 (SimpleXMLIterator loses ancestry)
+--SKIPIF--
+if (!extension_loaded("spl")) print "skip";
+if (!extension_loaded('simplexml')) print 'skip';
+if (!extension_loaded("libxml")) print "skip LibXML not present";
+if (!class_exists('RecursiveIteratorIterator')) print 'skip RecursiveIteratorIterator not available';
+--FILE--
+<?php
+$xml =<<<EOF
+<xml>
+ <fieldset1>
+ <field1/>
+ <field2/>
+ </fieldset1>
+ <fieldset2>
+ <options>
+ <option1/>
+ <option2/>
+ <option3/>
+ </options>
+ <field1/>
+ <field2/>
+ </fieldset2>
+</xml>
+EOF;
+
+$sxe = new SimpleXMLIterator($xml);
+$rit = new RecursiveIteratorIterator($sxe, RecursiveIteratorIterator::LEAVES_ONLY);
+foreach ($rit as $child) {
+ $path = '';
+ $ancestry = $child->xpath('ancestor-or-self::*');
+ foreach ($ancestry as $ancestor) {
+ $path .= $ancestor->getName() . '/';
+ }
+ $path = substr($path, 0, strlen($path) - 1);
+ echo count($ancestry) . ' steps: ' . $path . PHP_EOL;
+}
+?>
+===DONE===
+--EXPECT--
+3 steps: xml/fieldset1/field1
+3 steps: xml/fieldset1/field2
+4 steps: xml/fieldset2/options/option1
+4 steps: xml/fieldset2/options/option2
+4 steps: xml/fieldset2/options/option3
+3 steps: xml/fieldset2/field1
+3 steps: xml/fieldset2/field2
+===DONE===