php.net |  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: rick_g22 at yahoo dot com
New email:
PHP Version: OS:

 

 [2007-07-27 01:40 UTC] rick_g22 at yahoo dot com
Description:
------------
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:
---------------
<?php
// allow_call_time_pass_reference = On
// zend.ze1_compatibility_mode = On
class myclass {
  var $item = 1;
}

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

Expected result:
----------------
2

Actual result:
--------------
1

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-01 10:56 UTC] dmitry@php.net
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
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 21:01:27 2024 UTC