Skip to content

Commit 89bc095

Browse files
committed
Introduce PDO_HANDLE_STMT_ERR_EX
1 parent 8feb2d4 commit 89bc095

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

ext/pdo/pdo_stmt.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,14 +1276,7 @@ PHP_METHOD(PDOStatement, fetchAll)
12761276
stmt->fetch.cls.ce = old_ce;
12771277
stmt->fetch.cls.ctor_args = old_ctor_args;
12781278

1279-
/* Inline PDO_HANDLE_STMT_ERR(); as we need to free the return value */
1280-
if (UNEXPECTED(EG(exception) || strcmp(stmt->error_code, PDO_ERR_NONE) != 0)) {
1281-
zval_ptr_dtor(return_value);
1282-
if (strcmp(stmt->error_code, PDO_ERR_NONE) != 0) {
1283-
pdo_handle_error(stmt->dbh, stmt);
1284-
}
1285-
RETURN_EMPTY_ARRAY();
1286-
}
1279+
PDO_HANDLE_STMT_ERR_EX(zval_ptr_dtor(return_value); RETVAL_EMPTY_ARRAY(););
12871280
}
12881281
/* }}} */
12891282

ext/pdo/php_pdo_error.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ PDO_API void pdo_handle_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt);
3434
memcpy(stmt->error_code, PDO_ERR_NONE, sizeof(PDO_ERR_NONE)); \
3535
} while (0)
3636
#define PDO_HANDLE_DBH_ERR() if (strcmp(dbh->error_code, PDO_ERR_NONE)) { pdo_handle_error(dbh, NULL); }
37-
#define PDO_HANDLE_STMT_ERR() if (strcmp(stmt->error_code, PDO_ERR_NONE)) { pdo_handle_error(stmt->dbh, stmt); }
37+
#define PDO_HANDLE_STMT_ERR_EX(cleanup_instruction) if (strcmp(stmt->error_code, PDO_ERR_NONE) != 0) { cleanup_instruction pdo_handle_error(stmt->dbh, stmt); }
38+
#define PDO_HANDLE_STMT_ERR() PDO_HANDLE_STMT_ERR_EX(;)
3839

3940
#endif /* PHP_PDO_ERROR_H */

0 commit comments

Comments
 (0)