From 5ab1180e0ffce2aaa5eacc330cd19d36b0da563b Mon Sep 17 00:00:00 2001 From: Saki Takamachi Date: Thu, 18 Jul 2024 08:45:04 +0900 Subject: [PATCH] ext/pdo_firebird: Added getApiVersion() and removed from getAttribute --- NEWS | 2 ++ UPGRADING | 4 ++-- ext/pdo_firebird/firebird_driver.c | 4 ---- ext/pdo_firebird/pdo_firebird.c | 9 +++++++++ ext/pdo_firebird/pdo_firebird.stub.php | 5 ++--- ext/pdo_firebird/pdo_firebird_arginfo.h | 14 +++++++------- ext/pdo_firebird/php_pdo_firebird_int.h | 1 - ext/pdo_firebird/tests/get_api_version.phpt | 6 ++---- 8 files changed, 24 insertions(+), 21 deletions(-) diff --git a/NEWS b/NEWS index 9bd95f0ee20f1..1dc9004d47fea 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,8 @@ PHP NEWS - PDO_FIREBIRD: . Added Pdo\Firebird::ATTR_API_VERSION. (SakiTakamachi) + . Added getApiVersion() and removed from getAttribute(). + (SakiTakamachi) - Standard: . Fix references in request_parse_body() options array. (nielsdos) diff --git a/UPGRADING b/UPGRADING index a25b16e6a34c9..93654728efaf8 100644 --- a/UPGRADING +++ b/UPGRADING @@ -510,8 +510,8 @@ PHP 8.4 UPGRADE NOTES . When using persistent connections, there is now a liveness check in the constructor. . The content that is built changes depending on the value of FB_API_VER in - ibase.h, so added the attribute value Pdo\Firebird::ATTR_API_VERSION to - obtain that value. This value can also be referenced from phpinfo. + ibase.h, so added static method Pdo\Firebird::getApiVersion() to obtain that + value. This value can also be referenced from phpinfo. - PDO_MYSQL: . getAttribute, enabled to get the value of ATTR_FETCH_TABLE_NAMES. diff --git a/ext/pdo_firebird/firebird_driver.c b/ext/pdo_firebird/firebird_driver.c index 2368682be9136..beeb4352940eb 100644 --- a/ext/pdo_firebird/firebird_driver.c +++ b/ext/pdo_firebird/firebird_driver.c @@ -1177,10 +1177,6 @@ static int pdo_firebird_get_attribute(pdo_dbh_t *dbh, zend_long attr, zval *val) } return 1; - case PDO_FB_ATTR_API_VERSION: - ZVAL_LONG(val, FB_API_VER); - return 1; - case PDO_ATTR_SERVER_VERSION: case PDO_ATTR_SERVER_INFO: *tmp = 0; diff --git a/ext/pdo_firebird/pdo_firebird.c b/ext/pdo_firebird/pdo_firebird.c index 4aa6943239260..0fbdb7f8c97c5 100644 --- a/ext/pdo_firebird/pdo_firebird.c +++ b/ext/pdo_firebird/pdo_firebird.c @@ -100,3 +100,12 @@ PHP_MINFO_FUNCTION(pdo_firebird) /* {{{ */ php_info_print_table_end(); } /* }}} */ + +PHP_METHOD(Pdo_Firebird, getApiVersion) +{ + if (zend_parse_parameters_none() == FAILURE) { + RETURN_THROWS(); + } + + RETURN_LONG(FB_API_VER); +} diff --git a/ext/pdo_firebird/pdo_firebird.stub.php b/ext/pdo_firebird/pdo_firebird.stub.php index 3187d4a09e993..f8c9ea46fcb07 100644 --- a/ext/pdo_firebird/pdo_firebird.stub.php +++ b/ext/pdo_firebird/pdo_firebird.stub.php @@ -19,9 +19,6 @@ class Firebird extends \PDO /** @cvalue PDO_FB_ATTR_TIMESTAMP_FORMAT */ public const int ATTR_TIMESTAMP_FORMAT = UNKNOWN; - /** @cvalue PDO_FB_ATTR_API_VERSION */ - public const int ATTR_API_VERSION = UNKNOWN; - /** @cvalue PDO_FB_TRANSACTION_ISOLATION_LEVEL */ public const int TRANSACTION_ISOLATION_LEVEL = UNKNOWN; @@ -36,4 +33,6 @@ class Firebird extends \PDO /** @cvalue PDO_FB_WRITABLE_TRANSACTION */ public const int WRITABLE_TRANSACTION = UNKNOWN; + + public static function getApiVersion(): int {} } diff --git a/ext/pdo_firebird/pdo_firebird_arginfo.h b/ext/pdo_firebird/pdo_firebird_arginfo.h index 95d9b16fa8bb5..a751751edb635 100644 --- a/ext/pdo_firebird/pdo_firebird_arginfo.h +++ b/ext/pdo_firebird/pdo_firebird_arginfo.h @@ -1,7 +1,13 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: bc0f434e238c1087e292be0d4a7a04aa4718a6bc */ + * Stub hash: d36b2055abc48ae91c3442dda68fa2a28eb6d25b */ + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Pdo_Firebird_getApiVersion, 0, 0, IS_LONG, 0) +ZEND_END_ARG_INFO() + +ZEND_METHOD(Pdo_Firebird, getApiVersion); static const zend_function_entry class_Pdo_Firebird_methods[] = { + ZEND_ME(Pdo_Firebird, getApiVersion, arginfo_class_Pdo_Firebird_getApiVersion, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) ZEND_FE_END }; @@ -31,12 +37,6 @@ static zend_class_entry *register_class_Pdo_Firebird(zend_class_entry *class_ent zend_declare_typed_class_constant(class_entry, const_ATTR_TIMESTAMP_FORMAT_name, &const_ATTR_TIMESTAMP_FORMAT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_ATTR_TIMESTAMP_FORMAT_name); - zval const_ATTR_API_VERSION_value; - ZVAL_LONG(&const_ATTR_API_VERSION_value, PDO_FB_ATTR_API_VERSION); - zend_string *const_ATTR_API_VERSION_name = zend_string_init_interned("ATTR_API_VERSION", sizeof("ATTR_API_VERSION") - 1, 1); - zend_declare_typed_class_constant(class_entry, const_ATTR_API_VERSION_name, &const_ATTR_API_VERSION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_API_VERSION_name); - zval const_TRANSACTION_ISOLATION_LEVEL_value; ZVAL_LONG(&const_TRANSACTION_ISOLATION_LEVEL_value, PDO_FB_TRANSACTION_ISOLATION_LEVEL); zend_string *const_TRANSACTION_ISOLATION_LEVEL_name = zend_string_init_interned("TRANSACTION_ISOLATION_LEVEL", sizeof("TRANSACTION_ISOLATION_LEVEL") - 1, 1); diff --git a/ext/pdo_firebird/php_pdo_firebird_int.h b/ext/pdo_firebird/php_pdo_firebird_int.h index a462eba5c6165..dc1e4bb7f4086 100644 --- a/ext/pdo_firebird/php_pdo_firebird_int.h +++ b/ext/pdo_firebird/php_pdo_firebird_int.h @@ -142,7 +142,6 @@ enum { PDO_FB_ATTR_DATE_FORMAT = PDO_ATTR_DRIVER_SPECIFIC, PDO_FB_ATTR_TIME_FORMAT, PDO_FB_ATTR_TIMESTAMP_FORMAT, - PDO_FB_ATTR_API_VERSION, /* * transaction isolation level diff --git a/ext/pdo_firebird/tests/get_api_version.phpt b/ext/pdo_firebird/tests/get_api_version.phpt index eeb77b62a6582..a8adccc0b2a4d 100644 --- a/ext/pdo_firebird/tests/get_api_version.phpt +++ b/ext/pdo_firebird/tests/get_api_version.phpt @@ -1,5 +1,5 @@ --TEST-- -PDO_Firebird: get api version +PDO_Firebird: getApiVersion() --EXTENSIONS-- pdo_firebird --SKIPIF-- @@ -9,9 +9,7 @@ A bug in firebird causes a memory leak when calling `isc_attach_database()`. See https://github.com/FirebirdSQL/firebird/issues/7849 --FILE-- getAttribute(Pdo\Firebird::ATTR_API_VERSION) . "\n"; +echo Pdo\Firebird::getApiVersion() . "\n"; echo 'done!'; ?> --EXPECTF--