Skip to content

Commit b44e29f

Browse files
committed
php_pdo_register_driver() might fail
Therefore correctly report failure in MINIT for the drivers which didn't.
1 parent 424b480 commit b44e29f

File tree

5 files changed

+11
-7
lines changed

5 files changed

+11
-7
lines changed

ext/pdo/pdo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ zend_module_entry pdo_module_entry = {
115115
ZEND_GET_MODULE(pdo)
116116
#endif
117117

118-
PDO_API int php_pdo_register_driver(const pdo_driver_t *driver) /* {{{ */
118+
PDO_API zend_result php_pdo_register_driver(const pdo_driver_t *driver) /* {{{ */
119119
{
120120
if (driver->api_version != PDO_DRIVER_API) {
121121
zend_error(E_ERROR, "PDO: driver %s requires PDO API version " ZEND_ULONG_FMT "; this is PDO version %d",

ext/pdo/php_pdo_driver.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,8 +655,9 @@ struct _pdo_row_t {
655655
pdo_stmt_t *stmt;
656656
};
657657

658-
/* call this in MINIT to register your PDO driver */
659-
PDO_API int php_pdo_register_driver(const pdo_driver_t *driver);
658+
/* Call this in MINIT to register the PDO driver.
659+
* Registering the driver might fail and should be reported accordingly in MINIT. */
660+
PDO_API zend_result php_pdo_register_driver(const pdo_driver_t *driver);
660661
/* call this in MSHUTDOWN to unregister your PDO driver */
661662
PDO_API void php_pdo_unregister_driver(const pdo_driver_t *driver);
662663

ext/pdo_firebird/pdo_firebird.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ PHP_MINIT_FUNCTION(pdo_firebird) /* {{{ */
5858
REGISTER_PDO_CLASS_CONST_LONG("FB_ATTR_TIME_FORMAT", (zend_long) PDO_FB_ATTR_TIME_FORMAT);
5959
REGISTER_PDO_CLASS_CONST_LONG("FB_ATTR_TIMESTAMP_FORMAT", (zend_long) PDO_FB_ATTR_TIMESTAMP_FORMAT);
6060

61-
php_pdo_register_driver(&pdo_firebird_driver);
61+
if (FAILURE == php_pdo_register_driver(&pdo_firebird_driver)) {
62+
return FAILURE;
63+
}
6264

6365
#ifdef ZEND_SIGNALS
6466
/* firebird replaces some signals at runtime, suppress warnings. */

ext/pdo_oci/pdo_oci.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ PHP_MINIT_FUNCTION(pdo_oci)
8787
REGISTER_PDO_CLASS_CONST_LONG("OCI_ATTR_MODULE", (zend_long)PDO_OCI_ATTR_MODULE);
8888
REGISTER_PDO_CLASS_CONST_LONG("OCI_ATTR_CALL_TIMEOUT", (zend_long)PDO_OCI_ATTR_CALL_TIMEOUT);
8989

90-
php_pdo_register_driver(&pdo_oci_driver);
90+
if (FAILURE == php_pdo_register_driver(&pdo_oci_driver)) {
91+
return FAILURE;
92+
}
9193

9294
// Defer OCI init to PHP_RINIT_FUNCTION because with php-fpm,
9395
// NLS_LANG is not yet available here.

ext/pdo_pgsql/pdo_pgsql.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ PHP_MINIT_FUNCTION(pdo_pgsql)
6565
REGISTER_PDO_CLASS_CONST_LONG("PGSQL_TRANSACTION_INERROR", (zend_long)PGSQL_TRANSACTION_INERROR);
6666
REGISTER_PDO_CLASS_CONST_LONG("PGSQL_TRANSACTION_UNKNOWN", (zend_long)PGSQL_TRANSACTION_UNKNOWN);
6767

68-
php_pdo_register_driver(&pdo_pgsql_driver);
69-
return SUCCESS;
68+
return php_pdo_register_driver(&pdo_pgsql_driver);
7069
}
7170
/* }}} */
7271

0 commit comments

Comments
 (0)