Bug #73462 [NEW]: Persistent connections don't set $connect_errno
From: php at darkain dot com
Operating system: Debian 8
PHP version: 7.0.12
Package: MySQLi related
Bug Type: Bug
Bug description:Persistent connections don't set $connect_errno
Description:
------------
Tested on:
PHP 5.6.27-1~dotdeb+7.1 (cli) (built: Oct 15 2016 01:36:00)
PHP 7.0.12-1~dotdeb+8.1 (cli) ( NTS )
mysqli_connect_errno() and $mysql->connect_errno are not set at all
after a successful persistent connection is re-connected.
In the example provided, the 3rd call to "new mysqli" is re-using the
connection from the first call, however after the 3rd "new mysqli",
mysqli_connect_errno() still returns the error code from the 2nd call,
rather than returning 0 for a successful reconnection. This makes it
virtually impossible to tell if the 3rd connection succeeded or not for
proper application level error handling.
Note: This also effects mysqli_connect_error() and
$mysqli->connect_error
Test script:
---------------
$server = 'p:192.168.1.99';
$user = 'USERNAME';
$pass = 'PASSWORD';
$db = 'DATABASE';
$mysql_1 = @new mysqli($server, $user, $pass, $db);
var_dump(mysqli_connect_errno());
@$mysql_1->close();
$mysql_2 = @new mysqli('DOESNT-EXIST', $user, $pass, $db);
var_dump(mysqli_connect_errno());
@$mysql_2->close();
$mysql_3 = @new mysqli($server, $user, $pass, $db);
var_dump(mysqli_connect_errno());
@$mysql_3->close();
Expected result:
----------------
int(0)
int(2005)
int(0)
Actual result:
--------------
int(0)
int(2005)
int(2005)
--
Edit bug report at https://bugs.php.net/bug.php?id=73462&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=73462&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=73462&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=73462&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=73462&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=73462&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=73462&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=73462&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=73462&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=73462&r=support
Expected behavior: https://bugs.php.net/fix.php?id=73462&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=73462&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=73462&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=73462&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=73462&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=73462&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=73462&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=73462&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=73462&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=73462&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=73462&r=mysqlcfg
Thread (1 message)
- php at darkain dot com