#39491 [Bgs]: MySQLi object destroys too early
ID: 39491
User updated by: zeke at cs-cart dot com
Reported By: zeke at cs-cart dot com
Status: Bogus
Bug Type: MySQLi related
Operating System: Linux
PHP Version: 5.2.0
New Comment:
===
Accessing object, which is being currently destroyed, through it's
global reference is nonsense
===
But why? It's not destroyed yet! It's just preparing to be destroyed.
BTW. Could you please specify why this code worked on earlier versions?
Previous Comments:
------------------------------------------------------------------------
[2006-11-13 09:50:48] tony2001@php.net
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().
------------------------------------------------------------------------
[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)