Skip to content

Commit 01a5077

Browse files
committed
Use RETURN_THROWS() after zend_throw_exception() in most of the extensions
1 parent a648608 commit 01a5077

File tree

19 files changed

+462
-457
lines changed

19 files changed

+462
-457
lines changed

ext/json/json.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ static PHP_FUNCTION(json_encode)
268268
if (encoder.error_code != PHP_JSON_ERROR_NONE) {
269269
smart_str_free(&buf);
270270
zend_throw_exception(php_json_exception_ce, php_json_get_error_msg(encoder.error_code), encoder.error_code);
271-
RETURN_FALSE;
271+
RETURN_THROWS();
272272
}
273273
}
274274

ext/mysqli/mysqli.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1267,7 +1267,7 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags
12671267
* argument passed by reference.
12681268
*/
12691269
zend_throw_exception(zend_ce_exception, "Parameter ctor_params must be an array", 0);
1270-
return;
1270+
RETURN_THROWS();
12711271
}
12721272
}
12731273

ext/pdo/pdo_dbh.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -226,15 +226,15 @@ static PHP_METHOD(PDO, dbh_constructor)
226226
snprintf(alt_dsn, sizeof(alt_dsn), "pdo.dsn.%s", data_source);
227227
if (FAILURE == cfg_get_string(alt_dsn, &ini_dsn)) {
228228
zend_throw_exception_ex(php_pdo_get_exception(), 0, "invalid data source name");
229-
return;
229+
RETURN_THROWS();
230230
}
231231

232232
data_source = ini_dsn;
233233
colon = strchr(data_source, ':');
234234

235235
if (!colon) {
236236
zend_throw_exception_ex(php_pdo_get_exception(), 0, "invalid data source name (via INI: %s)", alt_dsn);
237-
return;
237+
RETURN_THROWS();
238238
}
239239
}
240240

@@ -243,12 +243,12 @@ static PHP_METHOD(PDO, dbh_constructor)
243243
data_source = dsn_from_uri(data_source + sizeof("uri:")-1, alt_dsn, sizeof(alt_dsn));
244244
if (!data_source) {
245245
zend_throw_exception_ex(php_pdo_get_exception(), 0, "invalid data source URI");
246-
return;
246+
RETURN_THROWS();
247247
}
248248
colon = strchr(data_source, ':');
249249
if (!colon) {
250250
zend_throw_exception_ex(php_pdo_get_exception(), 0, "invalid data source name (via URI)");
251-
return;
251+
RETURN_THROWS();
252252
}
253253
}
254254

@@ -258,7 +258,7 @@ static PHP_METHOD(PDO, dbh_constructor)
258258
/* NB: don't want to include the data_source in the error message as
259259
* it might contain a password */
260260
zend_throw_exception_ex(php_pdo_get_exception(), 0, "could not find driver");
261-
return;
261+
RETURN_THROWS();
262262
}
263263

264264
dbh = Z_PDO_DBH_P(object);
@@ -567,14 +567,14 @@ static PHP_METHOD(PDO, beginTransaction)
567567

568568
if (dbh->in_txn) {
569569
zend_throw_exception_ex(php_pdo_get_exception(), 0, "There is already an active transaction");
570-
RETURN_FALSE;
570+
RETURN_THROWS();
571571
}
572572

573573
if (!dbh->methods->begin) {
574574
/* TODO: this should be an exception; see the auto-commit mode
575575
* comments below */
576576
zend_throw_exception_ex(php_pdo_get_exception(), 0, "This driver doesn't support transactions");
577-
RETURN_FALSE;
577+
RETURN_THROWS();
578578
}
579579

580580
if (dbh->methods->begin(dbh)) {
@@ -600,7 +600,7 @@ static PHP_METHOD(PDO, commit)
600600

601601
if (!dbh->in_txn) {
602602
zend_throw_exception_ex(php_pdo_get_exception(), 0, "There is no active transaction");
603-
RETURN_FALSE;
603+
RETURN_THROWS();
604604
}
605605

606606
if (dbh->methods->commit(dbh)) {
@@ -626,7 +626,7 @@ static PHP_METHOD(PDO, rollBack)
626626

627627
if (!dbh->in_txn) {
628628
zend_throw_exception_ex(php_pdo_get_exception(), 0, "There is no active transaction");
629-
RETURN_FALSE;
629+
RETURN_THROWS();
630630
}
631631

632632
if (dbh->methods->rollback(dbh)) {

ext/pgsql/pgsql.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2840,7 +2840,7 @@ static void php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, zend_long result_
28402840
* argument passed by reference.
28412841
*/
28422842
zend_throw_exception(zend_ce_exception, "Parameter ctor_params must be an array", 0);
2843-
return;
2843+
RETURN_THROWS();
28442844
}
28452845
}
28462846

0 commit comments

Comments
 (0)