Bug #67317 [NEW]: [PDO] $pdo = null doesn't close mysql connection if there are PDOStatements
| From: | bengates at aliceadsl dot fr | Date: | Wed, 21 May 2014 09:55:22 +0000 |
| Subject: | Bug #67317 [NEW]: [PDO] $pdo = null doesn't close mysql connection if there are PDOStatements | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-185880@lists.php.net to get a copy of this message | ||
From: bengates at aliceadsl dot fr
Operating system: Ubuntu
PHP version: 5.4.28
Package: PDO MySQL
Bug Type: Bug
Bug description:[PDO] $pdo = null doesn't close mysql connection if there are PDOStatements
Description:
------------
Hello,
I figured out that closing a PDO connection will only be effective if no
PDOStatement are open.
If you prepare multiple statements, setting the $pdo instance to null
will have no effect until you set any PDOStatement instance to null too.
Test script:
---------------
Examples :
<?php
$pdo = new Pdo("mysql:host=localhost", 'user', 'password');
$pdo = null;
sleep(10);
exit;
?>
=> Connection has sucessfully been closed and isn't visible in MySql
processlist within the 10 seconds for the script to terminate.
<?php
$pdo = new Pdo("mysql:host=localhost", 'user', 'password');
$stmt = $pdo->prepare("SELECT * FROM mytable WHERE Id = ?");
$pdo = null;
sleep(10);
exit;
?>
=> Connection hasn't been closed and is visible (Sleep) in MySql
processlist within the 10 seconds for the script to terminate.
<?php
$pdo = new Pdo("mysql:host=localhost", 'user', 'password');
$stmt = $pdo->prepare("SELECT * FROM mytable WHERE Id = ?");
$pdo = null;
$stmt = null;
sleep(10);
exit;
?>
=> Connection has sucessfully been closed and isn't visible in MySql
processlist within the 10 seconds for the script to terminate.
Expected result:
----------------
Setting the pdo instance to null should really close mysql's connection,
regardless of any PDOStatement instance still existing at this time.
--
Edit bug report at https://bugs.php.net/bug.php?id=67317&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=67317&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=67317&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=67317&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=67317&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=67317&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=67317&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=67317&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=67317&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=67317&r=support
Expected behavior: https://bugs.php.net/fix.php?id=67317&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=67317&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=67317&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=67317&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=67317&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=67317&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=67317&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=67317&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=67317&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=67317&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=67317&r=mysqlcfg