#39491 [Opn->Bgs]: MySQLi object destroys too early
ID: 39491
Updated by: tony2001@php.net
Reported By: zeke at cs-cart dot com
-Status: Open
+Status: Bogus
Bug Type: MySQLi related
Operating System: Linux
PHP Version: 5.2.0
New Comment:
It has nothing to do with the problem described in #33772.
Accessing object, which is being currently destroyed, through it's
global reference is nonsense. And nobody guaranteed that this reference
will exist at the moment where __destruct() is called.
Pass $this as an argument to sess_save().
Previous Comments:
------------------------------------------------------------------------
[2006-11-13 09:29:48] zeke at cs-cart dot com
Description:
------------
I think its related with
http://bugs.php.net/bug.php?id=33772
========
"Write and Close handlers are called after destructing objects since
PHP
5.0.5. Thus destructors can use sessions but session handler can't use
objects. In prior versions, they were called in the opposite order. It
is possible to call session_write_close() from the destructor to solve
this chicken and egg problem."
===========
It doesn't work since php 5.2.0.
Reproduce code:
---------------
<?php
function sess_save()
{
global $db_conn;
echo is_object($db_conn) ? "OK" : "FAIL";
}
class my_mysqli extends mysqli {
public function __destruct(){
sess_save();
}
}
$db_conn = new my_mysqli($db_host, $db_user, $db_password);
?>
Expected result:
----------------
In php 5 prior 5.2.0 displays:
"OK"
Actual result:
--------------
In php 5.2.0 displays:
"FAIL"
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=39491&edit=1
Thread (3 messages)