|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42119 array_push($arr,&$obj) doesn't work with zend.ze1_compatibility_mode On
Submitted: 2007-07-27 01:40 UTC Modified: 2007-08-01 10:56 UTC
From: rick_g22 at yahoo dot com Assigned: dmitry (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.2.3 OS: Win32
Private report: No CVE-ID: None
 [2007-07-27 01:40 UTC] rick_g22 at yahoo dot com
On PHP 5.2.3 (win32 version at least), php.ini disregards "allow_call_time_pass_reference = On" for objects, if
"zend.ze1_compatibility_mode = On". This is SPECIFICALLY for uses of array_push WITH ampersand, i.e. array_push($arr,&$obj) - this code worked perfectly in PHP4, and fails in PHP5.
Note 1: This bug is the opposite behavior of bug #30332 - #30332's example didn't use an ampersand when passing the objects, and this does.
Note 2: A workaround is $arr[] = &$obj;

Reproduce code:
// allow_call_time_pass_reference = On
// zend.ze1_compatibility_mode = On
class myclass {
  var $item = 1;

$arr = array();
$myobj = new myclass();
$myobj->item = 2;
echo $arr[0]->item;

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-01 10:56 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Feb 25 20:01:28 2024 UTC