summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorGeorge Peter Banyard <girgias@php.net>2021-01-19 12:54:42 +0000
committerGeorge Peter Banyard <girgias@php.net>2021-01-19 12:55:07 +0000
commitb44e29f8430189914ad4047176527918f80b935c (patch)
tree0573ad737518b18635be497fe651b45a825c4565 /ext
parent424b4802d2b3f3682ccef86bcb4a162832a4c12f (diff)
downloadphp-git-b44e29f8430189914ad4047176527918f80b935c.tar.gz
php_pdo_register_driver() might fail
Therefore correctly report failure in MINIT for the drivers which didn't.
Diffstat (limited to 'ext')
-rw-r--r--ext/pdo/pdo.c2
-rw-r--r--ext/pdo/php_pdo_driver.h5
-rw-r--r--ext/pdo_firebird/pdo_firebird.c4
-rw-r--r--ext/pdo_oci/pdo_oci.c4
-rw-r--r--ext/pdo_pgsql/pdo_pgsql.c3
5 files changed, 11 insertions, 7 deletions
diff --git a/ext/pdo/pdo.c b/ext/pdo/pdo.c
index 573de78cff..b5eb35e841 100644
--- a/ext/pdo/pdo.c
+++ b/ext/pdo/pdo.c
@@ -115,7 +115,7 @@ zend_module_entry pdo_module_entry = {
ZEND_GET_MODULE(pdo)
#endif
-PDO_API int php_pdo_register_driver(const pdo_driver_t *driver) /* {{{ */
+PDO_API zend_result php_pdo_register_driver(const pdo_driver_t *driver) /* {{{ */
{
if (driver->api_version != PDO_DRIVER_API) {
zend_error(E_ERROR, "PDO: driver %s requires PDO API version " ZEND_ULONG_FMT "; this is PDO version %d",
diff --git a/ext/pdo/php_pdo_driver.h b/ext/pdo/php_pdo_driver.h
index 775ffd240f..ed5518a017 100644
--- a/ext/pdo/php_pdo_driver.h
+++ b/ext/pdo/php_pdo_driver.h
@@ -655,8 +655,9 @@ struct _pdo_row_t {
pdo_stmt_t *stmt;
};
-/* call this in MINIT to register your PDO driver */
-PDO_API int php_pdo_register_driver(const pdo_driver_t *driver);
+/* Call this in MINIT to register the PDO driver.
+ * Registering the driver might fail and should be reported accordingly in MINIT. */
+PDO_API zend_result php_pdo_register_driver(const pdo_driver_t *driver);
/* call this in MSHUTDOWN to unregister your PDO driver */
PDO_API void php_pdo_unregister_driver(const pdo_driver_t *driver);
diff --git a/ext/pdo_firebird/pdo_firebird.c b/ext/pdo_firebird/pdo_firebird.c
index 086b7cab5f..29b8bc85a7 100644
--- a/ext/pdo_firebird/pdo_firebird.c
+++ b/ext/pdo_firebird/pdo_firebird.c
@@ -58,7 +58,9 @@ PHP_MINIT_FUNCTION(pdo_firebird) /* {{{ */
REGISTER_PDO_CLASS_CONST_LONG("FB_ATTR_TIME_FORMAT", (zend_long) PDO_FB_ATTR_TIME_FORMAT);
REGISTER_PDO_CLASS_CONST_LONG("FB_ATTR_TIMESTAMP_FORMAT", (zend_long) PDO_FB_ATTR_TIMESTAMP_FORMAT);
- php_pdo_register_driver(&pdo_firebird_driver);
+ if (FAILURE == php_pdo_register_driver(&pdo_firebird_driver)) {
+ return FAILURE;
+ }
#ifdef ZEND_SIGNALS
/* firebird replaces some signals at runtime, suppress warnings. */
diff --git a/ext/pdo_oci/pdo_oci.c b/ext/pdo_oci/pdo_oci.c
index efa7c1caf6..5ae28a50df 100644
--- a/ext/pdo_oci/pdo_oci.c
+++ b/ext/pdo_oci/pdo_oci.c
@@ -87,7 +87,9 @@ PHP_MINIT_FUNCTION(pdo_oci)
REGISTER_PDO_CLASS_CONST_LONG("OCI_ATTR_MODULE", (zend_long)PDO_OCI_ATTR_MODULE);
REGISTER_PDO_CLASS_CONST_LONG("OCI_ATTR_CALL_TIMEOUT", (zend_long)PDO_OCI_ATTR_CALL_TIMEOUT);
- php_pdo_register_driver(&pdo_oci_driver);
+ if (FAILURE == php_pdo_register_driver(&pdo_oci_driver)) {
+ return FAILURE;
+ }
// Defer OCI init to PHP_RINIT_FUNCTION because with php-fpm,
// NLS_LANG is not yet available here.
diff --git a/ext/pdo_pgsql/pdo_pgsql.c b/ext/pdo_pgsql/pdo_pgsql.c
index 4764419e47..9c711a883e 100644
--- a/ext/pdo_pgsql/pdo_pgsql.c
+++ b/ext/pdo_pgsql/pdo_pgsql.c
@@ -65,8 +65,7 @@ PHP_MINIT_FUNCTION(pdo_pgsql)
REGISTER_PDO_CLASS_CONST_LONG("PGSQL_TRANSACTION_INERROR", (zend_long)PGSQL_TRANSACTION_INERROR);
REGISTER_PDO_CLASS_CONST_LONG("PGSQL_TRANSACTION_UNKNOWN", (zend_long)PGSQL_TRANSACTION_UNKNOWN);
- php_pdo_register_driver(&pdo_pgsql_driver);
- return SUCCESS;
+ return php_pdo_register_driver(&pdo_pgsql_driver);
}
/* }}} */