diff --git a/.github/scripts/windows/test_task.bat b/.github/scripts/windows/test_task.bat index 124b9b019ca4b..223d654300357 100644 --- a/.github/scripts/windows/test_task.bat +++ b/.github/scripts/windows/test_task.bat @@ -58,12 +58,15 @@ if "%PLATFORM%" == "x64" ( curl -sLo Firebird.zip %PHP_FIREBIRD_DOWNLOAD_URL% 7z x -oC:\Firebird Firebird.zip set PDO_FIREBIRD_TEST_DATABASE=C:\test.fdb -set PDO_FIREBIRD_TEST_DSN=firebird:dbname=%PDO_FIREBIRD_TEST_DATABASE% +set PDO_FIREBIRD_TEST_DSN=firebird:dbname=127.0.0.1:%PDO_FIREBIRD_TEST_DATABASE% set PDO_FIREBIRD_TEST_USER=SYSDBA set PDO_FIREBIRD_TEST_PASS=phpfi +echo create user %PDO_FIREBIRD_TEST_USER% password '%PDO_FIREBIRD_TEST_PASS%';> C:\Firebird\create_user.sql +echo commit;>> C:\Firebird\create_user.sql echo create database '%PDO_FIREBIRD_TEST_DATABASE%' user '%PDO_FIREBIRD_TEST_USER%' password '%PDO_FIREBIRD_TEST_PASS%';> C:\Firebird\setup.sql C:\Firebird\instsvc.exe install -n TestInstance C:\Firebird\isql -q -i C:\Firebird\setup.sql +C:\Firebird\isql -q -i C:\Firebird\create_user.sql -user sysdba %PDO_FIREBIRD_TEST_DATABASE% C:\Firebird\instsvc.exe start -n TestInstance if %errorlevel% neq 0 exit /b 3 path C:\Firebird;%PATH% diff --git a/ext/pdo_firebird/firebird_driver.c b/ext/pdo_firebird/firebird_driver.c index 367d6a746b3ae..259ed53af98a8 100644 --- a/ext/pdo_firebird/firebird_driver.c +++ b/ext/pdo_firebird/firebird_driver.c @@ -594,7 +594,8 @@ static void firebird_handle_closer(pdo_dbh_t *dbh) /* {{{ */ } H->in_manually_txn = 0; - if (isc_detach_database(H->isc_status, &H->db)) { + /* isc_detach_database returns 0 on success, 1 on failure. */ + if (H->db && isc_detach_database(H->isc_status, &H->db)) { php_firebird_error(dbh); } diff --git a/ext/pdo_firebird/tests/gh17383.phpt b/ext/pdo_firebird/tests/gh17383.phpt new file mode 100644 index 0000000000000..6adad311938c6 --- /dev/null +++ b/ext/pdo_firebird/tests/gh17383.phpt @@ -0,0 +1,38 @@ +--TEST-- +GH-17383 (PDOException has wrong code and message since PHP 8.4) +--EXTENSIONS-- +pdo_firebird +--SKIPIF-- +<?php require('skipif.inc'); ?> +--XLEAK-- +A bug in firebird causes a memory leak when calling `isc_attach_database()`. +See https://github.com/FirebirdSQL/firebird/issues/7849 +--FILE-- +<?php + +require("testdb.inc"); +unset($dbh); + +foreach ([ + ['firebird:dbname=invalid_host:db', PDO_FIREBIRD_TEST_USER, PDO_FIREBIRD_TEST_PASS], + [PDO_FIREBIRD_TEST_DSN, 'invalid_user', PDO_FIREBIRD_TEST_PASS], + [PDO_FIREBIRD_TEST_DSN, PDO_FIREBIRD_TEST_USER, 'invalid_pass'], +] as [$dsn, $user, $pass]) { + try { + $dbh = new PDO($dsn, $user, $pass); + } catch (PDOException $e) { + echo 'PDOException code: ' . $e->getCode() . "\n"; + echo 'PDOException message: ' . $e->getMessage() . "\n"; + echo "\n"; + } +} +?> +--EXPECT-- +PDOException code: 335544721 +PDOException message: SQLSTATE[HY000] [335544721] Unable to complete network request to host "invalid_host". + +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. + +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.