Bug #80586 [NEW]: PDO constructor overrides dblib timeout
| From: | jeremys at ha dot com | Date: | Mon, 04 Jan 2021 15:21:40 +0000 |
| Subject: | Bug #80586 [NEW]: PDO constructor overrides dblib timeout | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-231360@lists.php.net to get a copy of this message | ||
From: jeremys at ha dot com
Operating system: RHEL 7.8
PHP version: 7.3.25
Package: PDO DBlib
Bug Type: Bug
Bug description:PDO constructor overrides dblib timeout
Description:
------------
When instantiating a new PDO instance with dblib as the driver, passing
a non-null value to $options causes PDO_DBLIB to override the configured
timeout and default it to 30 seconds for both connects and queries.
For example, when using FreeTDS with a defined query timeout of 300
seconds in freetds.conf ("timeout = 300"), passing an empty array or an
array with options that have nothing to do with timeouts sets the query
timeout to 30 seconds.
The gist is, passing $options to PDO::__construct() should only set the
driver options specifically defined in $options, not every driver
option.
https://github.com/php/php-src/blob/caa710037e663fd78f67533b29611183090068b2/ext/pdo_dblib/dblib_driver.c#L481
Test script:
---------------
test-1.php:
<?php
$pdo = new PDO( 'dblib:dbname=northwinds;host=contoso', 'username',
'password' );
try
{
$pdo->query( "WAITFOR DELAY '00:00:35'" );
var_dump( $pdo->query( "SELECT 'output' AS Output"
)->fetch()['Output'] );
}
catch( Throwable $e )
{
var_dump( stripos( $pdo->errorInfo()[2], 'DBPROCESS is dead or not
enabled' ) === 0 );
}
?>
test-2.php:
<?php
$pdo = new PDO( 'dblib:dbname=northwinds;host=contoso', 'username',
'password', [] );
try
{
$pdo->query( "WAITFOR DELAY '00:00:35'" );
var_dump( $pdo->query( "SELECT 'output' AS Output"
)->fetch()['Output'] );
}
catch( Throwable $e )
{
var_dump( stripos( $pdo->errorInfo()[2], 'DBPROCESS is dead or not
enabled' ) === 0 );
}
Expected result:
----------------
test-1.php:
string(6) "output"
test-2.php:
string(6) "output"
Actual result:
--------------
test-1.php:
string(6) "output"
test-2.php:
bool(true)
--
Edit bug report at https://bugs.php.net/bug.php?id=80586&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=80586&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=80586&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=80586&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=80586&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=80586&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=80586&r=support
Expected behavior: https://bugs.php.net/fix.php?id=80586&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=80586&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=80586&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=80586&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80586&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=80586&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=80586&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=80586&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=80586&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=80586&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=80586&r=mysqlcfg