Closed
Description
Description
Since PHP 8.4 in Windows the PDOException has wrong infos.
If PHP connects to a firebird server with an invalid password the call PDOException->getCode() returns 0.
In PHP 8.3.15 getCode() returns 335544472.
I dont know if linux is also affected or if this only happens in windows.
Other PDO is not affected. I checked PDO_Mysql. Code and message is OK.
The following code shows the problem.
<?php
// OS: Windows 11 (24H2)
// Firebird Server 4.0.5
// fbclient.dll (5.0.1 64bit) - Client Library Version => WI-V6.3.1.1469 Firebird 5.0
function testPdoException($dsn, $username, $password) {
try {
$pdo = new PDO($dsn, $username, $password);
} catch (PDOException $e) {
echo 'PDOException code: ' . $e->getCode() . PHP_EOL;
echo 'PDOException message: ' . $e->getMessage() . PHP_EOL;
}
}
// connect to firebird server with invalid password
testPdoException("firebird:dbname=localhost:database", "user", "invalidPassword");
// connect to unknown host
testPdoException("firebird:dbname=unknownHost:database", "user", "password");
Resulted in this output in PHP 8.4.2:
// connect to firebird server with invalid password
PDOException code: 0
PDOException message: SQLSTATE[08003] [0] invalid database handle (no active connection)
// connect to unknown host
PDOException code: 0
PDOException message: SQLSTATE[08003] [0] invalid database handle (no active connection)
But I expected this output instead like in PHP 8.3.15:
// connect to firebird server with invalid password
PDOException code: 335544472
PDOException message: SQLSTATE[HY000] [335544472] Your user name and password are not defined. Ask your database administrator to set up a Firebird login.
// connect to unknown host
PDOException code: 335544721
PDOException message: SQLSTATE[HY000] [335544721] Unable to complete network request to host "unknownHost".
PHP Version
PHP 8.4.2
Operating System
Windows 11 (24H2)