php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26873 Constructors have problems with parameters when result of new isn't assigned
Submitted: 2004-01-11 15:20 UTC Modified: 2004-02-18 03:02 UTC
From: richard at garandnet dot net Assigned:
Status: No Feedback Package: Class/Object related
PHP Version: 5CVS, 4CVS OS: *
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: richard at garandnet dot net
New email:
PHP Version: OS:

 

 [2004-01-11 15:20 UTC] richard at garandnet dot net
Description:
------------
 

Reproduce code:
---------------
class B
{
  function B($name) {
    $this->name = $name;
  }
}
class A
{
  function A($b) {
    print_r(get_object_vars($b));
  }
}

new A(new B("c"));
$bug = new A(new B("c"));

Expected result:
----------------
Output: 
Array ( [name] => c ) 
Array ( [name] => c ) 

Actual result:
--------------
Output: 
Array ( [name] => b Object ( [name] => *RECURSION* ) ) 
Array ( [name] => c ) 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-01-11 19:13 UTC] sniper@php.net
Output with latest PHP 5 (HEAD) cvs:

Array
(
    [name] => c
)
/usr/src/web/php/php5/Zend/zend_API.c(721) :  Freeing 0x40E4ACBC (32 bytes), script=t.php
/usr/src/web/php/php5/Zend/zend_hash.c(157) : Actual location (location was relayed)
/usr/src/web/php/php5/Zend/zend_execute.c(3095) :  Freeing 0x40E489CC (44 bytes), script=t.php
/usr/src/web/php/php5/Zend/zend_API.c(720) : Actual location (location was relayed)
/usr/src/web/php/php5/Zend/zend_execute.c(3094) :  Freeing 0x40E482C4 (16 bytes), script=t.php
/usr/src/web/php/php5/Zend/zend_objects.c(88) :  Freeing 0x40E4823C (12 bytes), script=t.php
=== Total 4 memory leaks detected ===

Output with latest PHP 4_3 checkout:

Array
(
    [name] => c
)
/usr/src/web/php/php4/Zend/zend_API.c(594) :  Freeing 0x08644A24 (44 bytes), script=t.php
/usr/src/web/php/php4/Zend/zend_API.c(582) : Actual location (location was relayed)
/usr/src/web/php/php4/Zend/zend_hash.c(188) :  Freeing 0x0864EC4C (32 bytes), script=t.php
/usr/src/web/php/php4/Zend/zend_execute.c(1979) :  Freeing 0x0864E4DC (12 bytes), script=t.php

 [2004-02-08 11:49 UTC] sniper@php.net
btw. What's the idea with doing this anyway?

 [2004-02-13 10:16 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip


 [2004-02-18 03:02 UTC] sniper@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Oct 08 22:01:27 2024 UTC