From:             benadin at ukr dot net
Operating system: FreeBSD 5.4
PHP version:      5.1.1
PHP Bug Type:     Variables related
Bug description:  References doesn't work in some cases strating from PHP 5.1.1

Description:
------------
In the code below method StructAddNodePointer gets a part (branch) of the
array (in the example $bar->dxml_struct_arr) and fills it. It works in PHP
5.0.5 but doesn't work in PHP 5.1.1. It seems in PHP 5.1.1 passing
&$dxml_struct_arr by reference doesn't work. Or may be it doesn't work
here: $pointer_tree_doc_value = &$bar->StructAddNodePointer('doc',
$bar->dxml_struct_arr);

Reproduce code:
---------------
class foo {
        function StructAddNode($tag, &$dxml_struct_arr, $attribs = array()) {
                $dxml_struct_arr[] = array(
                        'tag' => $tag,
                        'value' => null #array()
                );
                $index= (sizeof($dxml_struct_arr)-1);
                return $index;
        }
        function StructAddNodePointer($tag, &$dxml_struct_arr, $attribs =
array()) {
                $index = $this->StructAddNode($tag, $dxml_struct_arr, $attribs);
                return $dxml_struct_arr[$index]['value'];
        }
}
$bar = new foo();
$bar->dxml_struct_arr = array();
$pointer_tree_doc_value = &$bar->StructAddNodePointer('doc',
$bar->dxml_struct_arr);
$pointer_tree_head_value = &$bar->StructAddNodePointer('HEAD',
$pointer_tree_doc_value);
print_r($bar->dxml_struct_arr);

Expected result:
----------------
Array
(
    [0] => Array
        (
            [tag] => doc
            [value] => Array
                (
                    [0] => Array
                        (
                            [tag] => HEAD
                            [value] => 
                        )

                )

        )

)


Actual result:
--------------
Array
(
    [0] => Array
        (
            [tag] => doc
            [value] => 
        )

)


-- 
Edit bug report at http://bugs.php.net/?id=35905&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=35905&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): 
http://bugs.php.net/fix.php?id=35905&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=35905&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=35905&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=35905&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=35905&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=35905&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=35905&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=35905&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=35905&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=35905&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=35905&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=35905&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=35905&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=35905&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=35905&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=35905&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=35905&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=35905&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=35905&r=mysqlcfg

Reply via email to