]> granicus.if.org Git - php/commitdiff
- Fixed Bug #46048 (SimpleXML top-level @attributes not part of iterator)
authorDavid Coallier <davidc@php.net>
Tue, 3 Feb 2009 21:42:35 +0000 (21:42 +0000)
committerDavid Coallier <davidc@php.net>
Tue, 3 Feb 2009 21:42:35 +0000 (21:42 +0000)
- Added test for bug #46048

ext/simplexml/simplexml.c
ext/simplexml/tests/bug46048.phpt [new file with mode: 0644]

index bb5bc6f31e52b2198c008396954981556c4b8649..941aeeb64823d81764b65d3d25a11c1f385b3301 100644 (file)
@@ -1087,7 +1087,7 @@ static HashTable * sxe_get_prop_hash(zval *object, int is_debug TSRMLS_DC) /* {{
        if (!node) {
                return rv;
        }
-       if (is_debug) {
+       if (is_debug || sxe->iter.type != SXE_ITER_CHILD) {
                if (sxe->iter.type == SXE_ITER_ELEMENT) {
                        node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
                }
diff --git a/ext/simplexml/tests/bug46048.phpt b/ext/simplexml/tests/bug46048.phpt
new file mode 100644 (file)
index 0000000..e3eb4f5
--- /dev/null
@@ -0,0 +1,24 @@
+--TEST--
+Bug #46048 (SimpleXML top-level @attributes not part of iterator)
+--FILE--
+<?php
+$xml = '
+<data id="1">
+    <key>value</key>
+</data>
+';
+$obj = simplexml_load_string($xml);
+print_r(get_object_vars($obj));
+echo "Done\n";
+?>
+--EXPECT--     
+Array
+(
+    [@attributes] => Array
+        (
+            [id] => 1
+        )
+
+    [key] => value
+)
+Done