Bug #62344 [Opn->Csd]: Class instance unset when running __destruct

From: Date: Fri, 15 Jan 2021 14:14:13 +0000
Subject: Bug #62344 [Opn->Csd]: Class instance unset when running __destruct
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-231580@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=62344&edit=1 ID: 62344 Updated by: cmb@php.net Reported by: minghanwu at yahoo dot com Summary: Class instance unset when running __destruct -Status: Open +Status: Closed Type: Bug Package: Scripting Engine problem Operating System: Debian Linux PHP Version: 5.3.14 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: This is apparently fixed as of PHP 7.0.0[1]. [1] <https://3v4l.org/c55fY> Previous Comments: ------------------------------------------------------------------------ [2012-06-17 18:09:00] minghanwu at yahoo dot com Description: ------------ I use a code like below on a server with php 5.1.6 for long, and the expected result below is the ACTUAL output of the code. Recently I have a new server running 5.3.3 and no luck. The point is the class instance is not able to be referenced when it runs to __destruct(). I use some functions to help object cleaning easier. Any comment or help will be appreciated. Test script: --------------- class Database { function __destruct() { echo "Destroyed Database\n"; }} class Session { private $db; function __construct() { $this->db = new Database(); } function __destruct() { echo "Destroyed Session\n"; check(); } } $sess = new Session(); check(); die(); function check(){ global $sess; if(isset($sess)) echo "yes\n"; else echo "no\n"; } Expected result: ---------------- yes Destroyed Session yes Destroyed Database Actual result: -------------- yes Destroyed Session no Destroyed Database ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=62344&edit=1

« previous php.bugs (#231580) next »