php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79857 destructor no longer called when constructor exits
Submitted: 2020-07-14 10:54 UTC Modified: -
From: sjon@php.net Assigned:
Status: Closed Package: Class/Object related
PHP Version: 8.0.0alpha2 OS: archLinux
Private report: No CVE-ID: None
 [2020-07-14 10:54 UTC] sjon@php.net
Description:
------------
Not sure if this is intentional or not but it isn't documented. It might cause unexpected issues for people expecting the destructor to always be executed

originally found as https://3v4l.org/imPGg

Test script:
---------------
class cm404 {
	function __construct() {
		exit("construct\n");
	}
	
	function __destruct() {
		exit("destruct\n");
	}
}

new cm404();

Expected result:
----------------
construct
destruct


Actual result:
--------------
construct

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-07-20 13:30 UTC] nikic@php.net
Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=e3827cea4e5c41db1e45b4a47ca136d008974e16
Log: Fix bug #79857: Add upgrading note for exit dtor change
 [2020-07-20 13:30 UTC] nikic@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jun 20 19:01:30 2024 UTC