PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Structures » Tree » Bug #252

iunfinite recursion with xml -file

Details

Submitted2003-11-14 15:29 UTC
Fromkonrek at gmx dot net
Assignedcain
StatusClosed
PackageTree
PHP VersionIrrelevant
OSlinux
Roadmaps(Not assigned)

Comments

[2003-11-14 15:29 UTC] konrek at gmx dot net

Description:
------------
<?xml version="1.0" encoding="UTF-8"?>
<page id="1">
<step id="2">
<hello is="3">hallo
</hello>
</step>
</page>

causes infinite recursion

Reproduce code:
---------------
echo "<h2>Test for Tree</h2>";
imppear( 'Tree/Tree' );
// setup a memory tree using nested sets
$tree = Tree::setup( 'Memory_XML', 'test.xml' );

// read the data from the DB and build the tree internally
$data = $tree->setup();
print_r($data);
//print_r($tree->setupByRawData($array ));
echo "<br /> ";
print_r($tree);

Expected result:
----------------
normal Parsing of XML in Tree-Object

Actual result:
--------------
output:

1
tree_memory Object
(
[data] => Array
(
[1] => Array
(
[id] => 1
[name] => page
[level] => 0
[attributes] => Array
(
[id] => 1
) [parentId] => 0
[cdata] =>

[childId] => 2
[child] => Array
(
[id] => 2
[name] => step
[level] => 1
[attributes] => Array
(
[id] => 2
) [parentId] => 1
[cdata] =>

[parent] => Array
*RECURSION*
[childId] => 3
[child] => Array
(
[id] => 3
[name] => hello
[level] => 2
[attributes] => Array
(
[is] => 3
)

[parentId] => 2
[cdata] => hallo

[parent] => Array
*RECURSION*
)

[children] => Array
(
[0] => Array
(
[id] => 3
[name] => hello
[level] => 2
[attributes] => Array
(
[is] => 3
)

[parentId] => 2
[cdata] => hallo

[parent] => Array
(
[id] => 2
[name] => step
[level] => 1
[attributes] => Array
(
[id] => 2
)

[parentId] => 1
[cdata] =>

[parent] => Array
(
[id] => 1
[name] => page
[level] => 0
[attributes] => Array
(
[id] => 1
)

[parentId] => 0
[cdata] =>

[childId] => 2
[child] => Array *RECURSION*
[children] => Array
(
[0] => Array
(
[id] => 2
[name] => step
[level] => 1
[attributes] => Array
(
[id] => 2
) [parentId] => 1
[cdata] =>

[parent] => Array
*RECURSION*
[childId] => 3
[child] => Array
*RECURSION*
[children] => Array *RECURSION*
)

)

)

[childId] => 3
[child] => Array
(
[id] => 3
[name] => hello
[level] => 2
[attributes] => Array
(
[is] => 3
)

and so on

[2003-11-14 16:53 UTC] cain at php dot net

you should not use print_r here, but use $tree->varDump() instead, since the structure *is* recursive.