|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-07-19 16:47 UTC] msipria at suomi24 dot fi
Description: ------------ I have session handling class and i have db class that i pass to the session handling class. As of PHP 5.1.0b1 order of going throu __destructers have been changed, so at end eaven DB class exsist its __destucter has been runned. removing __destruct from DB class will not help, coz mysql link has own __destruct function that it will run. i realy hope this is bug (that can fix) and it will be fixed, other whay i'm stuck with 5.0.x or have to re write lots of source code. Reproduce code: --------------- http://www.wiofso.com/~msipria/testi.txt Expected result: ---------------- In PHP 5.0.x (working) __construct = LINK open = LINK read = LINK write = LINK close = LINK __destruct = KILLED LINK Actual result: -------------- In PHP 5.1.0b3 (tested b1-b3) (not working) __construct = LINK open = LINK read = LINK __destruct = KILLED LINK write = KILLED LINK close = KILLED LINK PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 06:00:01 2025 UTC |
Adding session_write_close() to the __destruct() function will restore the write, close, and destroy functions to their proper order. I use a custom session handler that extends my custom mysqli class. It automatically checks for lost database connections and attempts reconnects, etc. This is still a bug, but the following makes your custom session handler viable. public function __destruct(){ @session_write_close(); } Without session_write_close: starting session connecting to database destroying session writing session can't write, database connection does not exist connecting to database writing session closing session With session_write_close: starting session connecting to database writing session closing session destroying sessionI want to enter this as a new bug report but I expect it would be kicked out as a duplicate of 33635, which links to this bug. This seems related in that something has changed so that my mysqli link is closed before the shutdown_function is executed. The following code works in all php5 versions before 5.1beta3. <?php function shutdown() { global $link; echo mysqli_real_escape_string($link, 'foo'); } $servername = 'localhost'; $username = 'username'; $password = 'password'; $link = mysqli_init(); mysqli_real_connect($link, $servername, $username, $password); echo mysqli_real_escape_string($link, 'foo') . '<br />'; register_shutdown_function('shutdown'); ?> Expected Result: foo foo Actual Result: foo Warning: Couldn't fetch mysqli in c:\program files\apache group\Apache\htdocs\foo.php on line 7 and to further this annoying issue, why is it that the equivalent mysql function still works in 5.1b3? <?php function shutdown() { global $link; echo mysql_real_escape_string('foo', $link); } $servername = 'localhost'; $username = 'username'; $password = 'password'; $link = mysql_connect($servername, $username, $password); echo mysql_real_escape_string('foo', $link) . '<br />'; register_shutdown_function('shutdown'); ?> Expected Result: foo foo Actual Result: foo foo