php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30332 zend.ze1_compatibility_mode isnt fully compatable with array_push()
Submitted: 2004-10-05 23:35 UTC Modified: 2005-04-29 09:59 UTC
Votes:3
Avg. Score:5.0 ± 0.0
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:1 (33.3%)
From: justmanj at msu dot edu Assigned: andi (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.* (2005-04-29) OS: *
Private report: No CVE-ID: None
 [2004-10-05 23:35 UTC] justmanj at msu dot edu
Description:
------------
zend.ze1_compatibility_mode when turned on doesn't honor the same methodlogy as 4.x when passing a class for some parameters - it passes by reference in functions like array_push();

this behavior was not in 4.3.x, and the only workaround is the clone keyword, which should be added in the 4.3.x tree for backwards compatability.

Reproduce code:
---------------
<?
class x { };

$first = new x;
$second = $first;
$container = array();
array_push($container, $first);

$first->first = " im in the first";

print_r($first);
print_r($second);
print_r($container);


Expected result:
----------------
x Object
(
    [first] =>  im in the first
)

x Object
(
)

Array
(
    [0] => x Object
        (
        )
)

Actual result:
--------------
x Object
(
    [first] =>  im in the first
)

x Object
(
)

Array
(
    [0] => x Object
        (
            [first] =>  im in the first
        )
)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-04-13 09:48 UTC] justmanj at msu dot edu
tested with:

PHP 5.1.0-dev (cli) (built: Apr 13 2005 08:33:33)
Copyright (c) 1997-2005 The PHP Group
Zend Engine v2.1.0-dev, Copyright (c) 1998-2004 Zend Technologies

zend.ze1_compatibility_mode => On => On

produces:


C:\php5-win32-latest>php c:\web\ze1_test.php
x Object
(
    [first] =>  im in the first
)
x Object
(
)
Array
(
    [0] => x Object
        (
            [first] =>  im in the first
        )

)

which is not the design of php4

j
 [2005-04-16 01:46 UTC] sniper@php.net
Pushing back to Andi (would like to assign to Zeev too but..)

 [2005-04-29 09:59 UTC] dmitry@php.net
Fixed in CVS HEAD and PHP_5_0.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 07:01:29 2024 UTC