Bug #52393 [Fbk->Csd]: __destructor of parameter object called on return
| From: | r dot spliet at student dot tudelft dot nl | Date: | Tue, 27 Jul 2010 10:35:44 +0000 |
| Subject: | Bug #52393 [Fbk->Csd]: __destructor of parameter object called on return | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-152838@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=52393&edit=1
ID: 52393
User updated by: r dot spliet at student dot tudelft dot nl
Reported by: r dot spliet at student dot tudelft dot nl
Summary: __destructor of parameter object called on return
-Status: Feedback
+Status: Closed
Type: Bug
Package: Class/Object related
Operating System: Fedora 13
PHP Version: 5.3.2
Block user comment: N
New Comment:
My apologies. My problems were not related to class destruction on
itself, but on the behaviour of mysql_connect(). A different object's
destructor was (correctly) called, leading to the confusion.
debug_print_backtrace() confirmed PHP's behaviour is correct and
documented.
Previous Comments:
------------------------------------------------------------------------
[2010-07-27 01:05:11] kalle@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.
A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc. If the script requires a
database to demonstrate the issue, please make sure it creates
all necessary tables, stored procedures etc.
Please avoid embedding huge scripts into the report.
------------------------------------------------------------------------
[2010-07-21 20:23:48] r dot spliet at student dot tudelft dot nl
Description:
------------
The situation is as following:
class mysqlControl holds a MySQL connection. This class has a
__destruct() method to close this connection properly
Class x has one of these mysqlControl objects as a private variable.
Class y has a method to represent itself in a MySQL way, and needs to
escape a string. For this it needs the mysqlControl that class X holds.
Now what happens is that Class x calls Class y's method to represent
itself in some form that's useful to query MySQL. As a parameter to y's
method X gives it's mysqlControl. Before y's method actually starts
executing, mysqlControl's destructor is called. This means the
connection is closed, and everything breaks.
Expected result:
----------------
I expected method y to not call mysqlControl's destructor but just uses
the mysqlControl given and forgets about it.
Actual result:
--------------
mysqlControl's destructor gets called, breaking the
mysql_real_escape_string() method before it could be used by class Y's
method.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=52393&edit=1