summaryrefslogtreecommitdiff
path: root/ext/sqlite3/sqlite3.c
diff options
context:
space:
mode:
authorNikita Popov <nikic@php.net>2015-04-02 18:52:32 +0200
committerNikita Popov <nikic@php.net>2015-04-06 11:27:34 +0200
commit122d759618a42bff105971b923fbbb5be02e34b9 (patch)
treefd4487414ffa3f120c77b19b9eb7dc409659c57e /ext/sqlite3/sqlite3.c
parent884b0365dbe718f667d048dbc3d1cd9d9f12ab84 (diff)
downloadphp-git-122d759618a42bff105971b923fbbb5be02e34b9.tar.gz
Always throw TypeException on throwing zpp failures
Introduces a ZEND_PARSE_PARAMS_THROW flag for zpp, which forces to report FAILURE errors using a TypeException instead of a Warning, like it would happen in strict mode. Adds a zend_parse_parameters_throw() convenience function, which invokes zpp with this flag. Converts all cases I could identify, where we currently have throwing zpp usage in constructors and replaces them with this API. Error handling is still replaced to EH_THROW in some cases to handle other, domain-specific errors in constructors.
Diffstat (limited to 'ext/sqlite3/sqlite3.c')
-rw-r--r--ext/sqlite3/sqlite3.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c
index 028881f21a..94172048ca 100644
--- a/ext/sqlite3/sqlite3.c
+++ b/ext/sqlite3/sqlite3.c
@@ -103,18 +103,13 @@ PHP_METHOD(sqlite3, open)
char *filename, *encryption_key, *fullpath;
size_t filename_len, encryption_key_len = 0;
zend_long flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE;
- zend_error_handling error_handling;
db_obj = Z_SQLITE3_DB_P(object);
- zend_replace_error_handling(EH_THROW, NULL, &error_handling);
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "p|ls", &filename, &filename_len, &flags, &encryption_key, &encryption_key_len)) {
- zend_restore_error_handling(&error_handling);
+ if (FAILURE == zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls", &filename, &filename_len, &flags, &encryption_key, &encryption_key_len)) {
return;
}
- zend_restore_error_handling(&error_handling);
-
if (db_obj->initialised) {
zend_throw_exception(zend_exception_get_default(), "Already initialised DB Object", 0);
}
@@ -1600,17 +1595,15 @@ PHP_METHOD(sqlite3stmt, __construct)
php_sqlite3_free_list *free_item;
stmt_obj = Z_SQLITE3_STMT_P(object);
- zend_replace_error_handling(EH_THROW, NULL, &error_handling);
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "OS", &db_zval, php_sqlite3_sc_entry, &sql) == FAILURE) {
- zend_restore_error_handling(&error_handling);
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "OS", &db_zval, php_sqlite3_sc_entry, &sql) == FAILURE) {
return;
}
db_obj = Z_SQLITE3_DB_P(db_zval);
+ zend_replace_error_handling(EH_THROW, NULL, &error_handling);
SQLITE3_CHECK_INITIALIZED(db_obj, db_obj->initialised, SQLite3)
-
zend_restore_error_handling(&error_handling);
if (!sql->len) {