ID:               38572
 Updated by:       [EMAIL PROTECTED]
 Reported By:      richardkmiller at gmail dot com
-Status:           Open
+Status:           Closed
 Bug Type:         Documentation problem
 Operating System: tested on Mac OS X and Windows
 PHP Version:      Irrelevant
 New Comment:

This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation
better.

"The destructor method will be called as soon as all references to a
particular object are removed or when the object is explicitly destroyed
or in any order in shutdown sequence."


Previous Comments:
------------------------------------------------------------------------

[2006-08-23 19:40:51] richardkmiller at gmail dot com

Description:
------------
The documentation for PHP 5 destructors (http://php.net/
manual/en/language.oop5.decon.php) says "The destructor method 
will be called as soon as all references to a particular 
object are removed..." but this may not always be true.

In PHP 5.1, the mysqli object is destroyed before the 
destructor of my class which refers to it, so I can't make 
mysqli calls from my destructor. 


Reproduce code:
---------------
<?php

$db = new mysqli('localhost', USERNAME, PASSWORD, DATABASE);

class Test
{
        public function __construct()
        {
                global $db;
                $db->query("SELECT 'test'");
        }
        public function __destruct()
        {
                global $db;
                $db->query("SELECT 'test'");  // line 15
        }
}

$test = new Test();

?>


Expected result:
----------------
I expect this code to produce no errors (no output).

Actual result:
--------------
This code produces the following warning:

Warning: mysqli::query() [function.mysqli-query]: Couldn't 
fetch mysqli in test.php on line 15

This bug appears to have been documented at #31326 and #36034.  
If it isn't planned to be fixed, the documentation should be 
updated to read the following (quoting [EMAIL PROTECTED] from 
#36034):

"You cannot rely on any order of destruction in shutdown 
sequence. All you can do is ensuring yourself that all related 
variables are set NULL or are being unset() prior to script 
end. If you do that in correct order then php calls the 
destructors in correct order."



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=38572&edit=1

Reply via email to