Skip to content

Commit 898bb97

Browse files
committed
Drop php_pdo_get_exception_base() function
This API is more confusing than helpful.
1 parent 33028bf commit 898bb97

File tree

3 files changed

+7
-17
lines changed

3 files changed

+7
-17
lines changed

ext/pdo/pdo.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,6 @@ PDO_API char *php_pdo_str_tolower_dup(const char *src, int len) /* {{{ */
7070
}
7171
/* }}} */
7272

73-
PDO_API zend_class_entry *php_pdo_get_exception_base(int root) /* {{{ */
74-
{
75-
if (!root) {
76-
return spl_ce_RuntimeException;
77-
}
78-
return zend_ce_exception;
79-
}
80-
/* }}} */
81-
8273
/* {{{ Return array of available PDO drivers */
8374
PHP_FUNCTION(pdo_drivers)
8475
{
@@ -315,7 +306,7 @@ PHP_MINIT_FUNCTION(pdo)
315306

316307
INIT_CLASS_ENTRY(ce, "PDOException", NULL);
317308

318-
pdo_exception_ce = zend_register_internal_class_ex(&ce, php_pdo_get_exception_base(0));
309+
pdo_exception_ce = zend_register_internal_class_ex(&ce, spl_ce_RuntimeException);
319310

320311
zend_declare_property_null(pdo_exception_ce, "errorInfo", sizeof("errorInfo")-1, ZEND_ACC_PUBLIC);
321312

ext/pdo/pdo_dbh.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,12 @@ void pdo_raise_impl_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *sqlstate
100100
php_error_docref(NULL, E_WARNING, "%s", message);
101101
} else {
102102
zval ex, info;
103-
zend_class_entry *def_ex = php_pdo_get_exception_base(1), *pdo_ex = php_pdo_get_exception();
103+
zend_class_entry *pdo_ex = php_pdo_get_exception();
104104

105105
object_init_ex(&ex, pdo_ex);
106106

107-
zend_update_property_string(def_ex, Z_OBJ(ex), "message", sizeof("message")-1, message);
108-
zend_update_property_string(def_ex, Z_OBJ(ex), "code", sizeof("code")-1, *pdo_err);
107+
zend_update_property_string(zend_ce_exception, Z_OBJ(ex), "message", sizeof("message")-1, message);
108+
zend_update_property_string(zend_ce_exception, Z_OBJ(ex), "code", sizeof("code")-1, *pdo_err);
109109

110110
array_init(&info);
111111

@@ -175,12 +175,12 @@ PDO_API void pdo_handle_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt) /* {{{ */
175175
php_error_docref(NULL, E_WARNING, "%s", ZSTR_VAL(message));
176176
} else if (EG(exception) == NULL) {
177177
zval ex;
178-
zend_class_entry *def_ex = php_pdo_get_exception_base(1), *pdo_ex = php_pdo_get_exception();
178+
zend_class_entry *pdo_ex = php_pdo_get_exception();
179179

180180
object_init_ex(&ex, pdo_ex);
181181

182-
zend_update_property_str(def_ex, Z_OBJ(ex), "message", sizeof("message") - 1, message);
183-
zend_update_property_string(def_ex, Z_OBJ(ex), "code", sizeof("code") - 1, *pdo_err);
182+
zend_update_property_str(zend_ce_exception, Z_OBJ(ex), "message", sizeof("message") - 1, message);
183+
zend_update_property_string(zend_ce_exception, Z_OBJ(ex), "code", sizeof("code") - 1, *pdo_err);
184184

185185
if (!Z_ISUNDEF(info)) {
186186
zend_update_property(pdo_ex, Z_OBJ(ex), "errorInfo", sizeof("errorInfo") - 1, &info);

ext/pdo/php_pdo_int.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
extern HashTable pdo_driver_hash;
2525
extern zend_class_entry *pdo_exception_ce;
26-
PDO_API zend_class_entry *php_pdo_get_exception_base(int root);
2726
int php_pdo_list_entry(void);
2827

2928
void pdo_dbh_init(void);

0 commit comments

Comments
 (0)