Bug #79586 [Opn->Nab]: Destructor is not called again if the previous attempt kept the object alive
| From: | nikic@php.net | Date: | Mon, 11 May 2020 12:06:21 +0000 |
| Subject: | Bug #79586 [Opn->Nab]: Destructor is not called again if the previous attempt kept the object alive | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-226994@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79586&edit=1
ID: 79586
Updated by: nikic@php.net
Reported by: michael dot vorisek at email dot cz
Summary: Destructor is not called again if the previous
attempt kept the object alive
-Status: Open
+Status: Not a bug
Type: Bug
Package: Scripting Engine problem
Operating System: any
PHP Version: 7.4.5
Block user comment: N
Private report: N
New Comment:
Destructor must be called at most once.
Previous Comments:
------------------------------------------------------------------------
[2020-05-11 11:32:51] michael dot vorisek at email dot cz
Description:
------------
Destructor has to be called on every attempt to release the object.
Test script:
---------------
class Registry {
public static $v;
}
$v = new class() extends \stdClass {
public function __destruct() {
var_dump($this);
Registry::$v = $this;
echo 'destroyed' . "\n";
}
};
unset($v);
var_dump(Registry::$v);
Registry::$v = null; // unset 2nd time
Expected result:
----------------
object(class@anonymous)#17 (0) {
}
destroyed
object(class@anonymous)#17 (0) {
}
object(class@anonymous)#17 (0) {
}
destroyed
Actual result:
--------------
object(class@anonymous)#17 (0) {
}
destroyed
object(class@anonymous)#17 (0) {
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79586&edit=1