summaryrefslogtreecommitdiff
path: root/ext/mysqli/mysqli.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/mysqli/mysqli.c')
-rw-r--r--ext/mysqli/mysqli.c58
1 files changed, 31 insertions, 27 deletions
diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c
index bdab4b7d1e..dcc5a16d5e 100644
--- a/ext/mysqli/mysqli.c
+++ b/ext/mysqli/mysqli.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -69,7 +69,7 @@ zend_class_entry *mysqli_warning_class_entry;
zend_class_entry *mysqli_exception_class_entry;
-typedef zval *(*mysqli_read_t)(mysqli_object *obj, zval *rv);
+typedef int (*mysqli_read_t)(mysqli_object *obj, zval *rv, zend_bool quiet);
typedef int (*mysqli_write_t)(mysqli_object *obj, zval *newval);
typedef struct _mysqli_prop_handler {
@@ -200,7 +200,9 @@ static void mysqli_objects_free_storage(zend_object *object)
mysqli_object *intern = php_mysqli_fetch_object(object);
MYSQLI_RESOURCE *my_res = (MYSQLI_RESOURCE *)intern->ptr;
- my_efree(my_res);
+ if (my_res) {
+ efree(my_res);
+ }
zend_object_std_dtor(&intern->zo);
}
/* }}} */
@@ -279,10 +281,13 @@ static void mysqli_warning_free_storage(zend_object *object)
/* }}} */
/* {{{ mysqli_read_na */
-static zval *mysqli_read_na(mysqli_object *obj, zval *retval)
+static int mysqli_read_na(mysqli_object *obj, zval *retval, zend_bool quiet)
{
- zend_throw_error(NULL, "Cannot read property");
- return NULL;
+ if (!quiet) {
+ zend_throw_error(NULL, "Cannot read property");
+ }
+
+ return FAILURE;
}
/* }}} */
@@ -290,6 +295,7 @@ static zval *mysqli_read_na(mysqli_object *obj, zval *retval)
static int mysqli_write_na(mysqli_object *obj, zval *newval)
{
zend_throw_error(NULL, "Cannot write property");
+
return FAILURE;
}
/* }}} */
@@ -305,7 +311,11 @@ zval *mysqli_read_property(zval *object, zval *member, int type, void **cache_sl
obj = Z_MYSQLI_P(object);
if (Z_TYPE_P(member) != IS_STRING) {
- ZVAL_STR(&tmp_member, zval_get_string_func(member));
+ zend_string *str = zval_try_get_string_func(member);
+ if (UNEXPECTED(!str)) {
+ return &EG(uninitialized_zval);
+ }
+ ZVAL_STR(&tmp_member, str);
member = &tmp_member;
}
@@ -314,8 +324,9 @@ zval *mysqli_read_property(zval *object, zval *member, int type, void **cache_sl
}
if (hnd) {
- retval = hnd->read_func(obj, rv);
- if (retval == NULL) {
+ if (hnd->read_func(obj, rv, type == BP_VAR_IS) == SUCCESS || type != BP_VAR_IS) {
+ retval = rv;
+ } else {
retval = &EG(uninitialized_zval);
}
} else {
@@ -331,14 +342,18 @@ zval *mysqli_read_property(zval *object, zval *member, int type, void **cache_sl
/* }}} */
/* {{{ mysqli_write_property */
-void mysqli_write_property(zval *object, zval *member, zval *value, void **cache_slot)
+zval *mysqli_write_property(zval *object, zval *member, zval *value, void **cache_slot)
{
zval tmp_member;
mysqli_object *obj;
mysqli_prop_handler *hnd = NULL;
if (Z_TYPE_P(member) != IS_STRING) {
- ZVAL_STR(&tmp_member, zval_get_string_func(member));
+ zend_string *str = zval_try_get_string_func(member);
+ if (UNEXPECTED(!str)) {
+ return value;
+ }
+ ZVAL_STR(&tmp_member, str);
member = &tmp_member;
}
@@ -351,12 +366,14 @@ void mysqli_write_property(zval *object, zval *member, zval *value, void **cache
if (hnd) {
hnd->write_func(obj, value);
} else {
- zend_std_write_property(object, member, value, cache_slot);
+ value = zend_std_write_property(object, member, value, cache_slot);
}
if (member == &tmp_member) {
zval_ptr_dtor_str(&tmp_member);
}
+
+ return value;
}
/* }}} */
@@ -423,6 +440,7 @@ HashTable *mysqli_object_get_debug_info(zval *object, int *is_temp)
zval rv, member;
zval *value;
ZVAL_STR(&member, entry->name);
+
value = mysqli_read_property(object, &member, BP_VAR_IS, 0, &rv);
if (value != &EG(uninitialized_zval)) {
zend_hash_add(retval, Z_STR(member), value);
@@ -542,11 +560,7 @@ static PHP_GINIT_FUNCTION(mysqli)
mysqli_globals->report_mode = 0;
mysqli_globals->report_ht = 0;
mysqli_globals->allow_local_infile = 0;
-#ifdef HAVE_EMBEDDED_MYSQLI
- mysqli_globals->embedded = 1;
-#else
mysqli_globals->embedded = 0;
-#endif
mysqli_globals->rollback_on_cached_plink = FALSE;
}
/* }}} */
@@ -626,7 +640,6 @@ PHP_MINIT_FUNCTION(mysqli)
zend_declare_property_null(ce, "insert_id", sizeof("insert_id") - 1, ZEND_ACC_PUBLIC);
zend_declare_property_null(ce, "server_info", sizeof("server_info") - 1, ZEND_ACC_PUBLIC);
zend_declare_property_null(ce, "server_version", sizeof("server_version") - 1, ZEND_ACC_PUBLIC);
- zend_declare_property_null(ce, "stat", sizeof("stat") - 1, ZEND_ACC_PUBLIC);
zend_declare_property_null(ce, "sqlstate", sizeof("sqlstate") - 1, ZEND_ACC_PUBLIC);
zend_declare_property_null(ce, "protocol_version", sizeof("protocol_version") - 1, ZEND_ACC_PUBLIC);
zend_declare_property_null(ce, "thread_id", sizeof("thread_id") - 1, ZEND_ACC_PUBLIC);
@@ -1265,7 +1278,7 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags
ZVAL_COPY_VALUE(&dataset, return_value);
- object_and_properties_init(return_value, ce, NULL);
+ object_init_ex(return_value, ce);
if (!ce->default_properties_count && !ce->__set) {
Z_OBJ_P(return_value)->properties = Z_ARR(dataset);
} else {
@@ -1311,12 +1324,3 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags
}
}
/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */