php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47771 Exception during object construction from arg call calls object's destructor
Submitted: 2009-03-25 07:38 UTC Modified: 2009-03-26 10:18 UTC
From: ninzya at inbox dot lv Assigned: dmitry (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.3.0RC1 OS: Windows XP
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: ninzya at inbox dot lv
New email:
PHP Version: OS:

 

 [2009-03-25 07:38 UTC] ninzya at inbox dot lv
Description:
------------
If you create new object and pass to it's constructor argument from function call, that has thrown an exception, the object's constructor is not being called (which is correct behavior), but object's destructor is being called (which is not correct behavior). See reproduce code.

Reproduce code:
---------------
<?php

function throw_exc() {
  throw new Exception('TEST_EXCEPTION');
}

class Test {
  
  public function __construct() {
    echo 'Constr' ."\n";
  }
  
  public function __destruct() {
    echo 'Destr' ."\n";
  }
  
}

try {
  
  $T =new Test( throw_exc());
  
} catch( Exception $e) {
  echo 'Exception: ' .$e->getMessage();
}

?>



Expected result:
----------------
Exception: TEST_EXCEPTION

Actual result:
--------------
Destr
Exception: TEST_EXCEPTION

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-03-26 10:18 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: Sat Dec 21 15:01:29 2024 UTC