Skip to content

Commit 2368767

Browse files
committed
Merge branch 'PHP-8.4'
* PHP-8.4: Fixed GH-17383 - pdo_firebird: PDOException has wrong code and message since PHP 8.4 (#18072)
2 parents 8376904 + 685baf7 commit 2368767

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

.github/scripts/windows/test_task.bat

+4-1
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,15 @@ if "%PLATFORM%" == "x64" (
5858
curl -sLo Firebird.zip %PHP_FIREBIRD_DOWNLOAD_URL%
5959
7z x -oC:\Firebird Firebird.zip
6060
set PDO_FIREBIRD_TEST_DATABASE=C:\test.fdb
61-
set PDO_FIREBIRD_TEST_DSN=firebird:dbname=%PDO_FIREBIRD_TEST_DATABASE%
61+
set PDO_FIREBIRD_TEST_DSN=firebird:dbname=127.0.0.1:%PDO_FIREBIRD_TEST_DATABASE%
6262
set PDO_FIREBIRD_TEST_USER=SYSDBA
6363
set PDO_FIREBIRD_TEST_PASS=phpfi
64+
echo create user %PDO_FIREBIRD_TEST_USER% password '%PDO_FIREBIRD_TEST_PASS%';> C:\Firebird\create_user.sql
65+
echo commit;>> C:\Firebird\create_user.sql
6466
echo create database '%PDO_FIREBIRD_TEST_DATABASE%' user '%PDO_FIREBIRD_TEST_USER%' password '%PDO_FIREBIRD_TEST_PASS%';> C:\Firebird\setup.sql
6567
C:\Firebird\instsvc.exe install -n TestInstance
6668
C:\Firebird\isql -q -i C:\Firebird\setup.sql
69+
C:\Firebird\isql -q -i C:\Firebird\create_user.sql -user sysdba %PDO_FIREBIRD_TEST_DATABASE%
6770
C:\Firebird\instsvc.exe start -n TestInstance
6871
if %errorlevel% neq 0 exit /b 3
6972
path C:\Firebird;%PATH%

ext/pdo_firebird/firebird_driver.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,8 @@ static void firebird_handle_closer(pdo_dbh_t *dbh) /* {{{ */
594594
}
595595
H->in_manually_txn = 0;
596596

597-
if (isc_detach_database(H->isc_status, &H->db)) {
597+
/* isc_detach_database returns 0 on success, 1 on failure. */
598+
if (H->db && isc_detach_database(H->isc_status, &H->db)) {
598599
php_firebird_error(dbh);
599600
}
600601

ext/pdo_firebird/tests/gh17383.phpt

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
--TEST--
2+
GH-17383 (PDOException has wrong code and message since PHP 8.4)
3+
--EXTENSIONS--
4+
pdo_firebird
5+
--SKIPIF--
6+
<?php require('skipif.inc'); ?>
7+
--XLEAK--
8+
A bug in firebird causes a memory leak when calling `isc_attach_database()`.
9+
See https://github.com/FirebirdSQL/firebird/issues/7849
10+
--FILE--
11+
<?php
12+
13+
require("testdb.inc");
14+
unset($dbh);
15+
16+
foreach ([
17+
['firebird:dbname=invalid_host:db', PDO_FIREBIRD_TEST_USER, PDO_FIREBIRD_TEST_PASS],
18+
[PDO_FIREBIRD_TEST_DSN, 'invalid_user', PDO_FIREBIRD_TEST_PASS],
19+
[PDO_FIREBIRD_TEST_DSN, PDO_FIREBIRD_TEST_USER, 'invalid_pass'],
20+
] as [$dsn, $user, $pass]) {
21+
try {
22+
$dbh = new PDO($dsn, $user, $pass);
23+
} catch (PDOException $e) {
24+
echo 'PDOException code: ' . $e->getCode() . "\n";
25+
echo 'PDOException message: ' . $e->getMessage() . "\n";
26+
echo "\n";
27+
}
28+
}
29+
?>
30+
--EXPECT--
31+
PDOException code: 335544721
32+
PDOException message: SQLSTATE[HY000] [335544721] Unable to complete network request to host "invalid_host".
33+
34+
PDOException code: 335544472
35+
PDOException message: SQLSTATE[HY000] [335544472] Your user name and password are not defined. Ask your database administrator to set up a Firebird login.
36+
37+
PDOException code: 335544472
38+
PDOException message: SQLSTATE[HY000] [335544472] Your user name and password are not defined. Ask your database administrator to set up a Firebird login.

0 commit comments

Comments
 (0)