|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34377 Access to MySQLi object lost in shutdown function
Submitted: 2005-09-05 17:52 UTC Modified: 2005-09-05 18:29 UTC
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:0 (0.0%)
From: freddie at bingham dot net Assigned:
Status: Not a bug Package: MySQLi related
PHP Version: 5.1.0RC1 OS: Windows XP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: freddie at bingham dot net
New email:
PHP Version: OS:


 [2005-09-05 17:52 UTC] freddie at bingham dot net
This bug ( reports the same php error but involves session handlers.

This bug ( describes a possible reason this problem to be working as designed.

As reported bu the php team:

"This is chicken/egg problem and it cannot be solved. One expect that
destructors are called before session close the other uses object for
save handlers."

Are we to assume that a change has been made that is calling destructors before session close?  Fine, but why is this affecting register_shutdown? If register_shutdown() is part of the request, we expect to have access to the same scope.   Secondly why is this just affecting MySQLi?  Go ahead and reproduce the example code using MySQL and you'll see that it works as expected.

Reproduce code:
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 />';

Expected result:

Actual result:
Warning: Couldn't fetch mysqli in c:\program files\apache
group\Apache\htdocs\foo.php on line 7


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-09-05 18:29 UTC]
Object destructors are executed before the request shutdown functions set by users. This will not change. Please don't submit any more duplicate reports about this issue.

PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed Aug 17 15:05:45 2022 UTC