Bug #62344 [NEW]: Class instance unset when running __destruct
| From: | minghanwu at yahoo dot com | Date: | Sun, 17 Jun 2012 18:09:01 +0000 |
| Subject: | Bug #62344 [NEW]: Class instance unset when running __destruct | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-171330@lists.php.net to get a copy of this message | ||
From: minghanwu at yahoo dot com
Operating system: Debian Linux
PHP version: 5.3.14
Package: Scripting Engine problem
Bug Type: Bug
Bug description:Class instance unset when running __destruct
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 bug report at https://bugs.php.net/bug.php?id=62344&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=62344&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=62344&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=62344&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=62344&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=62344&r=needdocs
Fixed in release: https://bugs.php.net/fix.php?id=62344&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=62344&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=62344&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=62344&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=62344&r=support
Expected behavior: https://bugs.php.net/fix.php?id=62344&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=62344&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=62344&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=62344&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=62344&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=62344&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=62344&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=62344&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=62344&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=62344&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=62344&r=mysqlcfg