summaryrefslogtreecommitdiff
path: root/ext/mysqli
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-02-26 15:32:18 +0100
committerNikita Popov <nikita.ppv@gmail.com>2019-06-05 14:25:07 +0200
commita31f46421d7bf6f55dd9ac5876b8e2eacf7e0708 (patch)
tree24ffd7c5ae5e321c3994048fdd0fd9f68ae7457c /ext/mysqli
parent528aa7932a839fc6319979c34aa372805d8dc41c (diff)
downloadphp-git-a31f46421d7bf6f55dd9ac5876b8e2eacf7e0708.tar.gz
Allow exceptions in __toString()
RFC: https://wiki.php.net/rfc/tostring_exceptions And convert some object to string conversion related recoverable fatal errors into Error exceptions. Improve exception safety of internal code performing string conversions.
Diffstat (limited to 'ext/mysqli')
-rw-r--r--ext/mysqli/mysqli.c6
-rw-r--r--ext/mysqli/mysqli_api.c9
2 files changed, 13 insertions, 2 deletions
diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c
index 394a838512..9964ea0be4 100644
--- a/ext/mysqli/mysqli.c
+++ b/ext/mysqli/mysqli.c
@@ -309,6 +309,9 @@ zval *mysqli_read_property(zval *object, zval *member, int type, void **cache_sl
if (Z_TYPE_P(member) != IS_STRING) {
ZVAL_STR(&tmp_member, zval_get_string_func(member));
member = &tmp_member;
+ if (EG(exception)) {
+ return &EG(uninitialized_zval);
+ }
}
if (obj->prop_handler != NULL) {
@@ -342,6 +345,9 @@ zval *mysqli_write_property(zval *object, zval *member, zval *value, void **cach
if (Z_TYPE_P(member) != IS_STRING) {
ZVAL_STR(&tmp_member, zval_get_string_func(member));
member = &tmp_member;
+ if (EG(exception)) {
+ return value;
+ }
}
obj = Z_MYSQLI_P(object);
diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c
index 1a7303c987..13d21e9312 100644
--- a/ext/mysqli/mysqli_api.c
+++ b/ext/mysqli/mysqli_api.c
@@ -899,7 +899,10 @@ PHP_FUNCTION(mysqli_stmt_execute)
if (!(stmt->param.is_null[i] = (Z_ISNULL_P(param)))) {
switch (stmt->stmt->params[i].buffer_type) {
case MYSQL_TYPE_VAR_STRING:
- convert_to_string_ex(param);
+ if (!try_convert_to_string(param)) {
+ return;
+ }
+
stmt->stmt->params[i].buffer = Z_STRVAL_P(param);
stmt->stmt->params[i].buffer_length = Z_STRLEN_P(param);
break;
@@ -1781,7 +1784,9 @@ PHP_FUNCTION(mysqli_options)
if (expected_type != Z_TYPE_P(mysql_value)) {
switch (expected_type) {
case IS_STRING:
- convert_to_string_ex(mysql_value);
+ if (!try_convert_to_string(mysql_value)) {
+ return;
+ }
break;
case IS_LONG:
convert_to_long_ex(mysql_value);