From: cf0hay at gmail dot com
Operating system: Hardened Gentoo Linux 64
PHP version: 5.5.4
Package: PDO related
Bug Type: Bug
Bug description:PDOStatement::fetch() does not throw exception on broken server
connection
Description:
------------
Using PDO with mysqlnd driver.
PDO instance was asked to throw exceptions, but calling fetch() after
the TCP connection broke does not throw an exception, it just emits a
warning instead, "Empty row packet body".
The server is located on a different computer on the network, cannot use
unix socket to reach it.
Test script:
---------------
$conn = new PDO(
'mysql:host=192.168.1.2;dbname=somedb;charset=utf8',
'somedbuser',
'somedbpass',
array(
PDO::ATTR_PERSISTENT => false,
PDO::ATTR_EMULATE_PREPARES => false,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_STRINGIFY_FETCHES => false,
PDO::ATTR_AUTOCOMMIT => true,
PDO::MYSQL_ATTR_INIT_COMMAND => "SET time_zone =
'+00:00'",
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => false,
PDO::MYSQL_ATTR_DIRECT_QUERY => false,
PDO::MYSQL_ATTR_FOUND_ROWS => false,
)
);
$res = $conn->query("
any query which gives back a lot of rows
");
while($row = $res->fetch(PDO::FETCH_ASSOC)){
//during this loop runs, terminate the connection with
something, like iptables
var_export($row);
}
var_export($row);
Expected result:
----------------
PDOStatement::fetch() should throw an exception as the server connection
has gone away (trying to do a new PDO::query() after does throw an
exception with that error message).
Actual result:
--------------
The script above just emits a warning and finishes the loop returning
false the very same way as if there were no more rows left from the
query.
--
Edit bug report at https://bugs.php.net/bug.php?id=65825&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=65825&r=trysnapshot54
Try a snapshot (PHP 5.5):
https://bugs.php.net/fix.php?id=65825&r=trysnapshot55
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=65825&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=65825&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=65825&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=65825&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=65825&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=65825&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=65825&r=support
Expected behavior: https://bugs.php.net/fix.php?id=65825&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=65825&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=65825&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=65825&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65825&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=65825&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=65825&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=65825&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=65825&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=65825&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=65825&r=mysqlcfg