Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pdo_firebird: PDOException has wrong code and message since PHP 8.4 #17383

Open
basc opened this issue Jan 6, 2025 · 0 comments
Open

pdo_firebird: PDOException has wrong code and message since PHP 8.4 #17383

basc opened this issue Jan 6, 2025 · 0 comments

Comments

@basc
Copy link

basc commented Jan 6, 2025

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants