php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39457 Multiple invoked OO connections never close
Submitted: 2006-11-10 12:00 UTC Modified: 2008-03-08 14:56 UTC
Votes:7
Avg. Score:3.1 ± 0.3
Reproduced:7 of 7 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (14.3%)
From: josh at mykoala dot com Assigned: andrey (profile)
Status: Closed Package: MySQLi related
PHP Version: 5.2.0 OS: OS X 10.4.8
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: josh at mykoala dot com
New email:
PHP Version: OS:

 

 [2006-11-10 12:00 UTC] josh at mykoala dot com
Description:
------------
After invoking multiple identical connect() calls to a MySQLi 
object (after mysqli_init), only one is closed via close() or 
script termination.

Reproduce code:
---------------
# only when invoked through apache

$db = mysqli_init();

$db->connect(null, 'root');
$db->connect(null, 'root');

$db->close();

Expected result:
----------------
Just like when using procedural MySQLi functions (or via 
mysql_* funcs), multiple connect() calls will not result in 
rogue db connections.

Actual result:
--------------
Checking the MySQL process list after each execution shows a 
rogue connection, which goes on until you reach max 
connections.

This only happens when using OO style.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-05-08 21:36 UTC] bugs dot php at david-salisbury dot co dot uk
I've experienced this behaviour on the latest PHP5 CVS (built May 8 2007 22:31:22) running in Apache 2.0.59 as mod_php5.

Further reproduce code if necessary:

<?php

$m = new mysqli();

$m->init();

$m->real_connect('localhost', 'root', 'pass', 'dbname');
$m->real_connect('localhost', 'root', 'pass', 'dbname');
$m->real_connect('localhost', 'root', 'pass', 'dbname');

?>
 [2007-06-28 20:14 UTC] sniper@php.net
Georg, reassign to someone else if this is not for you. :)
 [2007-10-23 00:18 UTC] josh at mykoala dot com
About to celebrate the two-year anniversary of this one, woo!  =)
 [2007-10-23 08:29 UTC] scottmac@php.net
It looks like a partial fix was added 6th of September for mysqli_connect, nothing for real_connect because calling mysql_close() destroys the mysql struct allocated by mysqli_init() so any values you had set would be lost.

This could potentially cause problems if say you disabled auto_commit or similar.
 [2008-01-12 15:32 UTC] hholzgra@php.net
This is actually a MySQL C API problem, too. mysql_real_connect() (the C API function that mysqli::real_connect() is built upon) does allow a 2nd connect on an already connected MYSQL structure, too, and the result is that a 2nd connection to the server is opened and the previous connection enters a "zombie" state ...

Now filed as MySQL bug: http://bugs.mysql.com/33831
 [2008-03-08 14:56 UTC] andrey@php.net
The fix will appear in 5.3.0
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jan 09 22:01:29 2025 UTC