[php-src] Issue #12038: An error occurs in set_attribute when using PDO SQLSRV

From: Date: Wed, 23 Aug 2023 15:10:52 +0000
Subject: [php-src] Issue #12038: An error occurs in set_attribute when using PDO SQLSRV
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-245234@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/12038 Author: SakiTakamachi ### Description The following code: ```php <?php // my env $pdo = new PDO('sqlsrv:server=mssql-server;database=test;', 'test_user', 'p@ssw0rd'); $pdo->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); ``` Resulted in this output: ``` Fatal error: Uncaught PDOException: SQLSTATE[IMSSP]: An invalid attribute was designated on the PDO object. in /var/www/html/test.php:5 Stack trace: #0 /var/www/html/test.php(5): PDO->setAttribute(17, false) #1 {main} thrown in /var/www/html/test.php on line 5 ``` A change here is triggering the error. https://github.com/php/php-src/pull/11622 The essence of the problem is that PDO SQLSRV is throwing an error instead of returning false when set_attribute fails. https://github.com/microsoft/msphpsql/pull/1468 I've been working on this issue for about 20 days now and the hotfix for PDO SQLSRV has not yet been released and things are looking a little shady. However, since there are many people who are in trouble, I thought about creating a PR for a workaround with php-src. What do you think? remarks: I've checked all the PDO drivers provided by PECL and found that only one, PDO SQLSRV, gives an error under the same conditions. ### PHP Version PHP 8.1.22+, 8.2.9+, 8.3.0+ ### Operating System _No response_

« previous php.bugs (#245234) next »