A fix for PHP 5.1.2 and bug://report/1 where the XML module would fail because we...
authorRobert Sesek <rsesek@bluestatic.org>
Wed, 25 Jan 2006 04:24:27 +0000 (04:24 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Wed, 25 Jan 2006 04:24:27 +0000 (04:24 +0000)
to a referenced argument

xml.php

diff --git a/xml.php b/xml.php
index 955a4a8bbc37e676da5c8121554865a48b5aea9b..d8e659446c893fcb7336a3eb624ff2361bd67074 100644 (file)
--- a/xml.php
+++ b/xml.php
@@ -202,6 +202,9 @@ class XML
        */
        function handle_tag_start(&$parser, $name, $attrs)
        {
+               // we need to keep track of indicies to monitor the last key in $this->attribs
+               static $index;
+               
                // trim attributes
                array_walk($attrs, 'trim');
 
@@ -217,12 +220,16 @@ class XML
                        }
                        
                        // create a new child node
-                       $this->attach_node($this->attribs["$name"][] = (array)$attrs);
+                       $this->attribs["$name"][ $index["$name"] ] = (array)$attrs;
+                       $this->attach_node($this->attribs["$name"][ $index["$name"] ]);
+                       $index["$name"]++;
                }
                // node set doesn't exist, so create it
                else
                {
-                       $this->attach_node($this->attribs["$name"] = (array)$attrs);
+                       $this->attribs["$name"] = (array)$attrs;
+                       $this->attach_node($this->attribs["$name"]);
+                       $index["$name"] = 1;
                }
        }