diff options
Diffstat (limited to 'ext/mysqli')
-rw-r--r-- | ext/mysqli/mysqli.c | 17 | ||||
-rw-r--r-- | ext/mysqli/mysqli_api.c | 22 | ||||
-rw-r--r-- | ext/mysqli/mysqli_driver.c | 2 | ||||
-rw-r--r-- | ext/mysqli/mysqli_exception.c | 2 | ||||
-rw-r--r-- | ext/mysqli/mysqli_fe.c | 50 | ||||
-rw-r--r-- | ext/mysqli/mysqli_nonapi.c | 8 | ||||
-rw-r--r-- | ext/mysqli/mysqli_priv.h | 4 | ||||
-rw-r--r-- | ext/mysqli/mysqli_prop.c | 8 | ||||
-rw-r--r-- | ext/mysqli/mysqli_result_iterator.c | 1 | ||||
-rw-r--r-- | ext/mysqli/mysqli_warning.c | 2 | ||||
-rw-r--r-- | ext/mysqli/php_mysqli_structs.h | 4 | ||||
-rw-r--r-- | ext/mysqli/tests/bug71863.phpt | 36 | ||||
-rw-r--r-- | ext/mysqli/tests/bug72701.phpt | 32 | ||||
-rw-r--r-- | ext/mysqli/tests/bug74595.phpt | 25 | ||||
-rw-r--r-- | ext/mysqli/tests/bug75018.phpt | 38 | ||||
-rw-r--r-- | ext/mysqli/tests/mysqli_class_mysqli_reflection.phpt | 9 | ||||
-rw-r--r-- | ext/mysqli/tests/mysqli_fetch_object.phpt | 37 | ||||
-rw-r--r-- | ext/mysqli/tests/mysqli_fetch_object_oo.phpt | 15 | ||||
-rw-r--r-- | ext/mysqli/tests/mysqli_get_client_stats.phpt | 8 |
19 files changed, 233 insertions, 87 deletions
diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c index d26f32d652..a42dcc20ee 100644 --- a/ext/mysqli/mysqli.c +++ b/ext/mysqli/mysqli.c @@ -34,6 +34,7 @@ #include "php_mysqli_structs.h" #include "mysqli_priv.h" #include "zend_exceptions.h" +#include "ext/spl/spl_exceptions.h" #include "zend_interfaces.h" ZEND_DECLARE_MODULE_GLOBALS(mysqli) @@ -282,7 +283,7 @@ static void mysqli_warning_free_storage(zend_object *object) /* {{{ mysqli_read_na */ static zval *mysqli_read_na(mysqli_object *obj, zval *retval) { - php_error_docref(NULL, E_ERROR, "Cannot read property"); + zend_throw_error(NULL, "Cannot read property"); return NULL; } /* }}} */ @@ -290,7 +291,7 @@ static zval *mysqli_read_na(mysqli_object *obj, zval *retval) /* {{{ mysqli_write_na */ static int mysqli_write_na(mysqli_object *obj, zval *newval) { - php_error_docref(NULL, E_ERROR, "Cannot write property"); + zend_throw_error(NULL, "Cannot write property"); return FAILURE; } /* }}} */ @@ -582,9 +583,7 @@ PHP_MINIT_FUNCTION(mysqli) mysqli_object_handlers.write_property = mysqli_write_property; mysqli_object_handlers.get_property_ptr_ptr = std_hnd->get_property_ptr_ptr; mysqli_object_handlers.has_property = mysqli_object_has_property; -#if PHP_VERSION_ID >= 50300 mysqli_object_handlers.get_debug_info = mysqli_object_get_debug_info; -#endif memcpy(&mysqli_object_driver_handlers, &mysqli_object_handlers, sizeof(zend_object_handlers)); mysqli_object_driver_handlers.free_obj = mysqli_driver_free_storage; memcpy(&mysqli_object_link_handlers, &mysqli_object_handlers, sizeof(zend_object_handlers)); @@ -603,11 +602,7 @@ PHP_MINIT_FUNCTION(mysqli) "MySqli persistent connection", module_number); INIT_CLASS_ENTRY(cex, "mysqli_sql_exception", mysqli_exception_methods); -#ifdef HAVE_SPL mysqli_exception_class_entry = zend_register_internal_class_ex(&cex, spl_ce_RuntimeException); -#else - mysqli_exception_class_entry = zend_register_internal_class_ex(&cex, zend_ce_exception); -#endif mysqli_exception_class_entry->ce_flags |= ZEND_ACC_FINAL; zend_declare_property_long(mysqli_exception_class_entry, "code", sizeof("code")-1, 0, ZEND_ACC_PROTECTED); zend_declare_property_string(mysqli_exception_class_entry, "sqlstate", sizeof("sqlstate")-1, "00000", ZEND_ACC_PROTECTED); @@ -999,9 +994,7 @@ PHP_MINFO_FUNCTION(mysqli) /* Dependancies */ static const zend_module_dep mysqli_deps[] = { -#if defined(HAVE_SPL) && (PHP_VERSION_ID >= 50100) ZEND_MOD_REQUIRED("spl") -#endif #if defined(MYSQLI_USE_MYSQLND) ZEND_MOD_REQUIRED("mysqlnd") #endif @@ -1296,9 +1289,7 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags if (ce->constructor) { fci.size = sizeof(fci); - fci.function_table = &ce->function_table; ZVAL_UNDEF(&fci.function_name); - fci.symbol_table = NULL; fci.object = Z_OBJ_P(return_value); fci.retval = &retval; fci.params = NULL; @@ -1320,7 +1311,7 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags fcc.initialized = 1; fcc.function_handler = ce->constructor; - fcc.calling_scope = EG(scope); + fcc.calling_scope = zend_get_executed_scope(); fcc.called_scope = Z_OBJCE_P(return_value); fcc.object = Z_OBJ_P(return_value); diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c index 6793fc8065..f0730839de 100644 --- a/ext/mysqli/mysqli_api.c +++ b/ext/mysqli/mysqli_api.c @@ -354,7 +354,7 @@ PHP_FUNCTION(mysqli_stmt_bind_param) RETURN_FALSE; } - if (types_len != argc - start) { + if (types_len != (size_t)(argc - start)) { /* number of bind variables doesn't match number of elements in type definition string */ php_error_docref(NULL, E_WARNING, "Number of elements in type definition string doesn't match number of bind variables"); RETURN_FALSE; @@ -596,7 +596,7 @@ PHP_FUNCTION(mysqli_stmt_bind_result) MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID); - if (argc != mysql_stmt_field_count(stmt->stmt)) { + if ((uint)argc != mysql_stmt_field_count(stmt->stmt)) { php_error_docref(NULL, E_WARNING, "Number of bind variables doesn't match number of fields in prepared statement"); RETURN_FALSE; } @@ -1268,7 +1268,11 @@ PHP_FUNCTION(mysqli_fetch_lengths) MYSQL_RES *result; zval *mysql_result; unsigned int i, num_fields; - zend_ulong *ret; +#if defined(MYSQLI_USE_MYSQLND) + const size_t *ret; +#else + const zend_ulong *ret; +#endif if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &mysql_result, mysqli_result_class_entry) == FAILURE) { return; @@ -1328,7 +1332,7 @@ PHP_FUNCTION(mysqli_field_seek) } MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, "mysqli_result", MYSQLI_STATUS_VALID); - if (fieldnr < 0 || fieldnr >= mysql_num_fields(result)) { + if (fieldnr < 0 || (uint)fieldnr >= mysql_num_fields(result)) { php_error_docref(NULL, E_WARNING, "Invalid field offset"); RETURN_FALSE; } @@ -1695,10 +1699,6 @@ static int mysqli_options_get_option_zval_type(int option) { switch (option) { #ifdef MYSQLI_USE_MYSQLND -#if PHP_MAJOR_VERSION == 6 - /* PHP-7 doesn't supprt unicode */ - case MYSQLND_OPT_NUMERIC_AND_DATETIME_AS_UNICODE: -#endif case MYSQLND_OPT_NET_CMD_BUFFER_SIZE: case MYSQLND_OPT_NET_READ_BUFFER_SIZE: #ifdef MYSQLND_STRING_TO_INT_CONVERSION @@ -1779,11 +1779,7 @@ PHP_FUNCTION(mysqli_options) MYSQLI_FETCH_RESOURCE_CONN(mysql, mysql_link, MYSQLI_STATUS_INITIALIZED); #if !defined(MYSQLI_USE_MYSQLND) -#if PHP_API_VERSION < 20100412 - if ((PG(open_basedir) && PG(open_basedir)[0] != '\0') || PG(safe_mode)) { -#else if (PG(open_basedir) && PG(open_basedir)[0] != '\0') { -#endif if(mysql_option == MYSQL_OPT_LOCAL_INFILE) { RETURN_FALSE; } @@ -2339,7 +2335,7 @@ PHP_FUNCTION(mysqli_stmt_attr_set) MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID); if (mode_in < 0) { - php_error_docref(NULL, E_WARNING, "mode should be non-negative, %pd passed", mode_in); + php_error_docref(NULL, E_WARNING, "mode should be non-negative, " ZEND_LONG_FMT " passed", mode_in); RETURN_FALSE; } diff --git a/ext/mysqli/mysqli_driver.c b/ext/mysqli/mysqli_driver.c index 5a807dd9f9..36d0c58d10 100644 --- a/ext/mysqli/mysqli_driver.c +++ b/ext/mysqli/mysqli_driver.c @@ -150,7 +150,7 @@ const zend_function_entry mysqli_driver_methods[] = { PHP_FALIAS(embedded_server_start, mysqli_embedded_server_start, NULL) PHP_FALIAS(embedded_server_end, mysqli_embedded_server_end, NULL) #endif - {NULL, NULL, NULL} + PHP_FE_END }; /* }}} */ diff --git a/ext/mysqli/mysqli_exception.c b/ext/mysqli/mysqli_exception.c index 1aca7762a8..8663057fd2 100644 --- a/ext/mysqli/mysqli_exception.c +++ b/ext/mysqli/mysqli_exception.c @@ -32,7 +32,7 @@ /* {{{ mysqli_exception_methods[] */ const zend_function_entry mysqli_exception_methods[] = { - {NULL, NULL, NULL} + PHP_FE_END }; /* }}} */ diff --git a/ext/mysqli/mysqli_fe.c b/ext/mysqli/mysqli_fe.c index 4f1f4a3527..31f4160beb 100644 --- a/ext/mysqli/mysqli_fe.c +++ b/ext/mysqli/mysqli_fe.c @@ -63,10 +63,6 @@ ZEND_BEGIN_ARG_INFO(arginfo_class_mysqli_stmt_bind_param, 0) ZEND_ARG_VARIADIC_INFO(1, vars) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO(all_args_force_by_ref, 0) - ZEND_ARG_VARIADIC_INFO(1, vars) -ZEND_END_ARG_INFO() - ZEND_BEGIN_ARG_INFO_EX(arginfo_mysqli_poll, 0, 0, 4) ZEND_ARG_ARRAY_INFO(1, read, 1) ZEND_ARG_ARRAY_INFO(1, write, 1) @@ -243,18 +239,14 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_mysqli_fetch_object, 0, 0, 1) -#if PHP_VERSION_ID > 50399 MYSQLI_ZEND_ARG_OBJ_INFO_RESULT() ZEND_ARG_INFO(0, class_name) ZEND_ARG_ARRAY_INFO(0, params, 0) -#endif ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_mysqli_fetch_object, 0, 0, 0) -#if PHP_VERSION_ID > 50399 ZEND_ARG_INFO(0, class_name) ZEND_ARG_ARRAY_INFO(0, params, 0) -#endif ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_mysqli_kill, 0, 0, 2) @@ -269,6 +261,17 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_mysqli_query, 0, 0, 2) MYSQLI_ZEND_ARG_OBJ_INFO_LINK() ZEND_ARG_INFO(0, query) + ZEND_ARG_INFO(0, resultmode) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_mysqli_multi_query, 0, 0, 1) + MYSQLI_ZEND_ARG_OBJ_INFO_LINK() + ZEND_ARG_INFO(0, query) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_mysqli_real_query, 0, 0, 1) + MYSQLI_ZEND_ARG_OBJ_INFO_LINK() + ZEND_ARG_INFO(0, query) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_mysqli_prepare, 0, 0, 2) @@ -283,6 +286,19 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_mysqli_query, 0, 0, 1) ZEND_ARG_INFO(0, query) + ZEND_ARG_INFO(0, resultmode) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_mysqli_prepare, 0, 0, 1) + ZEND_ARG_INFO(0, query) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_mysqli_multi_query, 0, 0, 1) + ZEND_ARG_INFO(0, query) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_mysqli_real_query, 0, 0, 1) + ZEND_ARG_INFO(0, query) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_mysqli_options, 0, 0, 3) @@ -450,7 +466,7 @@ const zend_function_entry mysqli_functions[] = { PHP_FE(mysqli_insert_id, arginfo_mysqli_only_link) PHP_FE(mysqli_kill, arginfo_mysqli_kill) PHP_FE(mysqli_more_results, arginfo_mysqli_only_link) - PHP_FE(mysqli_multi_query, arginfo_mysqli_query) + PHP_FE(mysqli_multi_query, arginfo_mysqli_multi_query) PHP_FE(mysqli_next_result, arginfo_mysqli_only_link) PHP_FE(mysqli_num_fields, arginfo_mysqli_only_result) PHP_FE(mysqli_num_rows, arginfo_mysqli_only_result) @@ -464,7 +480,7 @@ const zend_function_entry mysqli_functions[] = { PHP_FE(mysqli_query, arginfo_mysqli_query) PHP_FE(mysqli_real_connect, arginfo_mysqli_real_connect) PHP_FE(mysqli_real_escape_string, arginfo_mysqli_real_escape_string) - PHP_FE(mysqli_real_query, arginfo_mysqli_query) + PHP_FE(mysqli_real_query, arginfo_mysqli_real_query) #if defined(MYSQLI_USE_MYSQLND) PHP_FE(mysqli_reap_async_query, arginfo_mysqli_only_link) #endif @@ -550,7 +566,7 @@ const zend_function_entry mysqli_link_methods[] = { PHP_FALIAS(get_warnings, mysqli_get_warnings, arginfo_mysqli_no_params) PHP_FALIAS(init,mysqli_init_method, arginfo_mysqli_no_params) PHP_FALIAS(kill,mysqli_kill, arginfo_class_mysqli_kill) - PHP_FALIAS(multi_query, mysqli_multi_query, arginfo_class_mysqli_query) + PHP_FALIAS(multi_query, mysqli_multi_query, arginfo_class_mysqli_multi_query) PHP_FALIAS(__construct, mysqli_link_construct, arginfo_mysqli_connect) PHP_FALIAS(more_results, mysqli_more_results, arginfo_mysqli_no_params) PHP_FALIAS(next_result, mysqli_next_result, arginfo_mysqli_no_params) @@ -559,7 +575,7 @@ const zend_function_entry mysqli_link_methods[] = { #if defined(MYSQLI_USE_MYSQLND) ZEND_FENTRY(poll, ZEND_FN(mysqli_poll), arginfo_mysqli_poll, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) #endif - PHP_FALIAS(prepare, mysqli_prepare, arginfo_class_mysqli_query) + PHP_FALIAS(prepare, mysqli_prepare, arginfo_class_mysqli_prepare) PHP_FALIAS(query, mysqli_query, arginfo_class_mysqli_query) PHP_FALIAS(real_connect, mysqli_real_connect, arginfo_class_mysqli_real_connect) PHP_FALIAS(real_escape_string, mysqli_real_escape_string, arginfo_class_mysqli_real_escape_string) @@ -567,7 +583,7 @@ const zend_function_entry mysqli_link_methods[] = { PHP_FALIAS(reap_async_query, mysqli_reap_async_query, arginfo_mysqli_no_params) #endif PHP_FALIAS(escape_string, mysqli_real_escape_string, arginfo_class_mysqli_real_escape_string) - PHP_FALIAS(real_query, mysqli_real_query, arginfo_class_mysqli_query) + PHP_FALIAS(real_query, mysqli_real_query, arginfo_class_mysqli_real_query) PHP_FALIAS(release_savepoint, mysqli_release_savepoint, arginfo_class_mysqli_release_savepoint) PHP_FALIAS(rollback, mysqli_rollback, arginfo_class_mysqli_rollback) PHP_FALIAS(savepoint, mysqli_savepoint, arginfo_class_mysqli_savepoint) @@ -583,7 +599,7 @@ const zend_function_entry mysqli_link_methods[] = { PHP_FALIAS(thread_safe, mysqli_thread_safe, arginfo_mysqli_no_params) PHP_FALIAS(use_result, mysqli_use_result, arginfo_mysqli_no_params) PHP_FALIAS(refresh,mysqli_refresh, arginfo_class_mysqli_refresh) - {NULL, NULL, NULL} + PHP_FE_END }; /* }}} */ @@ -608,7 +624,7 @@ const zend_function_entry mysqli_result_methods[] = { PHP_FALIAS(fetch_row, mysqli_fetch_row, arginfo_mysqli_no_params) PHP_FALIAS(field_seek, mysqli_field_seek, arginfo_class_mysqli_result_and_fieldnr) PHP_FALIAS(free_result, mysqli_free_result, arginfo_mysqli_no_params) - {NULL, NULL, NULL} + PHP_FE_END }; /* }}} */ @@ -636,12 +652,12 @@ const zend_function_entry mysqli_stmt_methods[] = { PHP_FALIAS(send_long_data, mysqli_stmt_send_long_data, arginfo_class_mysqli_stmt_send_long_data) PHP_FALIAS(free_result, mysqli_stmt_free_result, arginfo_mysqli_no_params) PHP_FALIAS(reset, mysqli_stmt_reset, arginfo_mysqli_no_params) - PHP_FALIAS(prepare, mysqli_stmt_prepare, arginfo_class_mysqli_query) + PHP_FALIAS(prepare, mysqli_stmt_prepare, arginfo_class_mysqli_prepare) PHP_FALIAS(store_result, mysqli_stmt_store_result, arginfo_mysqli_no_params) #if defined(MYSQLI_USE_MYSQLND) PHP_FALIAS(get_result, mysqli_stmt_get_result, arginfo_mysqli_no_params) #endif - {NULL, NULL, NULL} + PHP_FE_END }; /* }}} */ diff --git a/ext/mysqli/mysqli_nonapi.c b/ext/mysqli/mysqli_nonapi.c index d763dde11a..19b4ddda85 100644 --- a/ext/mysqli/mysqli_nonapi.c +++ b/ext/mysqli/mysqli_nonapi.c @@ -156,7 +156,7 @@ void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_conne } else { mysql->persistent = persistent = TRUE; - hash_key = strpprintf(0, "mysqli_%s_%s%ld%s%s%s", SAFE_STR(hostname), SAFE_STR(socket), + hash_key = strpprintf(0, "mysqli_%s_%s" ZEND_LONG_FMT "%s%s%s", SAFE_STR(hostname), SAFE_STR(socket), port, SAFE_STR(username), SAFE_STR(dbname), SAFE_STR(passwd)); @@ -206,14 +206,14 @@ void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_conne } } if (MyG(max_links) != -1 && MyG(num_links) >= MyG(max_links)) { - php_error_docref(NULL, E_WARNING, "Too many open links (%pd)", MyG(num_links)); + php_error_docref(NULL, E_WARNING, "Too many open links (" ZEND_LONG_FMT ")", MyG(num_links)); goto err; } if (persistent && MyG(max_persistent) != -1 && (MyG(num_active_persistent) + MyG(num_inactive_persistent))>= MyG(max_persistent)) { - php_error_docref(NULL, E_WARNING, "Too many open persistent links (%pd)", + php_error_docref(NULL, E_WARNING, "Too many open persistent links (" ZEND_LONG_FMT ")", MyG(num_active_persistent) + MyG(num_inactive_persistent)); goto err; } @@ -1092,7 +1092,7 @@ PHP_FUNCTION(mysqli_begin_transaction) } MYSQLI_FETCH_RESOURCE_CONN(mysql, mysql_link, MYSQLI_STATUS_VALID); if (flags < 0) { - php_error_docref(NULL, E_WARNING, "Invalid value for parameter flags (%pd)", flags); + php_error_docref(NULL, E_WARNING, "Invalid value for parameter flags (" ZEND_LONG_FMT ")", flags); err = TRUE; } if (!name_len) { diff --git a/ext/mysqli/mysqli_priv.h b/ext/mysqli/mysqli_priv.h index 6f1faede34..34c7a74779 100644 --- a/ext/mysqli/mysqli_priv.h +++ b/ext/mysqli/mysqli_priv.h @@ -78,10 +78,6 @@ extern void php_mysqli_report_error(const char *sqlstate, int errorno, const cha extern void php_mysqli_report_index(const char *query, unsigned int status); extern void php_mysqli_throw_sql_exception(char *sqlstate, int errorno, char *format, ...); -#ifdef HAVE_SPL -extern PHPAPI zend_class_entry *spl_ce_RuntimeException; -#endif - #define PHP_MYSQLI_EXPORT(__type) PHP_MYSQLI_API __type PHP_MYSQLI_EXPORT(zend_object *) mysqli_objects_new(zend_class_entry *); diff --git a/ext/mysqli/mysqli_prop.c b/ext/mysqli/mysqli_prop.c index e29b5685ad..2e1e333b39 100644 --- a/ext/mysqli/mysqli_prop.c +++ b/ext/mysqli/mysqli_prop.c @@ -15,8 +15,6 @@ | Author: Georg Richter <georg@php.net> | | Andrey Hristov <andrey@php.net> | +----------------------------------------------------------------------+ - - $Id$ */ #ifdef HAVE_CONFIG_H @@ -289,7 +287,11 @@ static zval *result_type_read(mysqli_object *obj, zval *retval) static zval *result_lengths_read(mysqli_object *obj, zval *retval) { MYSQL_RES *p; - zend_ulong *ret; +#if defined(MYSQLI_USE_MYSQLND) + const size_t *ret; +#else + const zend_ulong *ret; +#endif uint field_count; CHECK_STATUS(MYSQLI_STATUS_VALID); diff --git a/ext/mysqli/mysqli_result_iterator.c b/ext/mysqli/mysqli_result_iterator.c index e21e737036..f2c28d5e97 100644 --- a/ext/mysqli/mysqli_result_iterator.c +++ b/ext/mysqli/mysqli_result_iterator.c @@ -153,6 +153,7 @@ zend_object_iterator_funcs php_mysqli_result_iterator_funcs = { php_mysqli_result_iterator_current_key, php_mysqli_result_iterator_move_forward, php_mysqli_result_iterator_rewind, + NULL }; /* }}} */ diff --git a/ext/mysqli/mysqli_warning.c b/ext/mysqli/mysqli_warning.c index 37a3ffd29e..19a51735ad 100644 --- a/ext/mysqli/mysqli_warning.c +++ b/ext/mysqli/mysqli_warning.c @@ -315,7 +315,7 @@ PHP_METHOD(mysqli_warning, __construct) const zend_function_entry mysqli_warning_methods[] = { PHP_ME(mysqli_warning, __construct, NULL, ZEND_ACC_PROTECTED) PHP_ME(mysqli_warning, next, NULL, ZEND_ACC_PUBLIC) - {NULL, NULL, NULL} + PHP_FE_END }; /* }}} */ diff --git a/ext/mysqli/php_mysqli_structs.h b/ext/mysqli/php_mysqli_structs.h index cac74b99f5..df41cbeb52 100644 --- a/ext/mysqli/php_mysqli_structs.h +++ b/ext/mysqli/php_mysqli_structs.h @@ -216,10 +216,6 @@ extern zend_object_iterator *php_mysqli_result_get_iterator(zend_class_entry *ce extern void php_mysqli_fetch_into_hash_aux(zval *return_value, MYSQL_RES * result, zend_long fetchtype); -#ifdef HAVE_SPL -extern PHPAPI zend_class_entry *spl_ce_RuntimeException; -#endif - #define MYSQLI_DISABLE_MQ if (mysql->multi_query) { \ mysql_set_server_option(mysql->mysql, MYSQL_OPTION_MULTI_STATEMENTS_OFF); \ mysql->multi_query = 0; \ diff --git a/ext/mysqli/tests/bug71863.phpt b/ext/mysqli/tests/bug71863.phpt new file mode 100644 index 0000000000..ea0a78faeb --- /dev/null +++ b/ext/mysqli/tests/bug71863.phpt @@ -0,0 +1,36 @@ +--TEST-- +Bug #71863 Segfault when EXPLAIN with "Unknown Column" Error +--SKIPIF-- +<?php +require_once('skipif.inc'); +require_once('skipifconnectfailure.inc'); +require_once("connect.inc"); +if (!$IS_MYSQLND) { + die("skip mysqlnd only test"); +} +?> +--FILE-- +<?php +require_once("connect.inc"); + +$req = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket); + +// create db and table for test +mysqli_query($req, "DROP TABLE IF EXISTS test_bug_71863") or die(mysqli_error($req)); +mysqli_query($req, "CREATE TABLE test_bug_71863 (id INT UNSIGNED NOT NULL DEFAULT 0)") or die(mysqli_error($req)); + +// segfault if EXPLAIN + "Unknown column" error +mysqli_query($req, "EXPLAIN SELECT `id` FROM `test_bug_71863` WHERE `owner_id` = '2' AND `object_id` = '1' AND type = '0'") or die(mysqli_error($req)."\n"); + +?> +--CLEAN-- +<?php +require_once("connect.inc"); +if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); +if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bug_71863")) + printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); +mysqli_close($link); +?> +--EXPECTF-- +%AUnknown column 'owner_id' in 'where clause' diff --git a/ext/mysqli/tests/bug72701.phpt b/ext/mysqli/tests/bug72701.phpt new file mode 100644 index 0000000000..f0eb174172 --- /dev/null +++ b/ext/mysqli/tests/bug72701.phpt @@ -0,0 +1,32 @@ +--TEST-- +Bug #72701 mysqli_get_host_info() wrong output +--SKIPIF-- +<?php +require_once('skipif.inc'); +require_once('skipifconnectfailure.inc'); +require_once("connect.inc"); + +if ("127.0.0.1" != $host && "localhost" != $host) { + die("skip require 127.0.0.1 connection"); +} + +?> +--FILE-- +<?php + +require_once("connect.inc"); + +$con = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket); + +if (mysqli_connect_errno()) { + echo "Failed to connect to MySQL: " . mysqli_connect_error(); +} + +var_dump(preg_match(",(127.0.0.1|localhost) via .*,i", mysqli_get_host_info($con))); + +mysqli_close($con); +?> +==DONE== +--EXPECT-- +int(1) +==DONE== diff --git a/ext/mysqli/tests/bug74595.phpt b/ext/mysqli/tests/bug74595.phpt new file mode 100644 index 0000000000..9d017eaa82 --- /dev/null +++ b/ext/mysqli/tests/bug74595.phpt @@ -0,0 +1,25 @@ +--TEST-- +Bug #74595 (ReflectionMethod::getParameters returns incorrect number of parameters) +--SKIPIF-- +<?php +require_once('skipif.inc'); +?> +--FILE-- +<?php +$class = new ReflectionClass('mysqli'); +$method = $class->getMethod('query'); +var_dump($method->getParameters()); +?> +--EXPECTF-- +array(2) { + [0]=> + object(ReflectionParameter)#%d (1) { + ["name"]=> + string(5) "query" + } + [1]=> + object(ReflectionParameter)#%d (1) { + ["name"]=> + string(10) "resultmode" + } +} diff --git a/ext/mysqli/tests/bug75018.phpt b/ext/mysqli/tests/bug75018.phpt new file mode 100644 index 0000000000..20d836166b --- /dev/null +++ b/ext/mysqli/tests/bug75018.phpt @@ -0,0 +1,38 @@ +--TEST-- +Bug #75018 Data corruption when reading fields of bit type +--SKIPIF-- +<?php +require_once('skipif.inc'); +require_once('skipifconnectfailure.inc'); +?> +--FILE-- +<?php +require_once("connect.inc"); + +$mysqli = new mysqli("$host:$port", $user, $passwd, $db); + +$tbl = "test_bug75018"; +$sql = "DROP TABLE IF EXISTS $tbl"; +$mysqli->query($sql); + +$sql = "CREATE TABLE $tbl (bit_column_1 bit(16) NOT NULL) DEFAULT CHARSET=utf8"; +$mysqli->query($sql); + +$sql = "INSERT INTO $tbl (bit_column_1) VALUES (0)"; +$mysqli->query($sql); +$sql = "INSERT INTO $tbl (bit_column_1) VALUES (0b10101010101)"; +$mysqli->query($sql); + +$sql = "SELECT bit_column_1 FROM $tbl"; +$result = $mysqli->query($sql); + +while ($row = $result->fetch_assoc()) { + var_dump($row['bit_column_1']); +} + +?> +==DONE== +--EXPECT-- +string(1) "0" +string(4) "1365" +==DONE== diff --git a/ext/mysqli/tests/mysqli_class_mysqli_reflection.phpt b/ext/mysqli/tests/mysqli_class_mysqli_reflection.phpt index 22829ee6ee..f85d68932b 100644 --- a/ext/mysqli/tests/mysqli_class_mysqli_reflection.phpt +++ b/ext/mysqli/tests/mysqli_class_mysqli_reflection.phpt @@ -732,7 +732,7 @@ isInternal: yes isUserDefined: no returnsReference: no Modifiers: 256 -Number of Parameters: 1 +Number of Parameters: 2 Number of Required Parameters: 1 Inspecting parameter 'query' of method 'query' @@ -742,6 +742,13 @@ isPassedByReference: no isOptional: no isDefaultValueAvailable: no +Inspecting parameter 'resultmode' of method 'query' +isArray: no +allowsNull: no +isPassedByReference: no +isOptional: yes +isDefaultValueAvailable: no + Inspecting method 'real_connect' isFinal: no isAbstract: no diff --git a/ext/mysqli/tests/mysqli_fetch_object.phpt b/ext/mysqli/tests/mysqli_fetch_object.phpt index 9706ceac84..dff91531ce 100644 --- a/ext/mysqli/tests/mysqli_fetch_object.phpt +++ b/ext/mysqli/tests/mysqli_fetch_object.phpt @@ -59,18 +59,25 @@ require_once('skipifconnectfailure.inc'); } - $obj = mysqli_fetch_object($res, 'mysqli_fetch_object_construct', array()); - - if (($obj->ID !== "3") || ($obj->label !== "c") || ($obj->a !== NULL) || ($obj->b !== NULL) || (get_class($obj) != 'mysqli_fetch_object_construct')) { - printf("[006] Object seems wrong. [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - var_dump($obj); - } + try { + $obj = mysqli_fetch_object($res, 'mysqli_fetch_object_construct', array()); + if (($obj->ID !== "3") || ($obj->label !== "c") || ($obj->a !== NULL) || ($obj->b !== NULL) || (get_class($obj) != 'mysqli_fetch_object_construct')) { + printf("[006] Object seems wrong. [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + var_dump($obj); + } + } catch (Throwable $e) { + echo "Exception: " . $e->getMessage() . "\n"; + } - $obj = mysqli_fetch_object($res, 'mysqli_fetch_object_construct', array('a')); - if (($obj->ID !== "4") || ($obj->label !== "d") || ($obj->a !== 'a') || ($obj->b !== NULL) || (get_class($obj) != 'mysqli_fetch_object_construct')) { - printf("[007] Object seems wrong. [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - var_dump($obj); - } + try { + $obj = mysqli_fetch_object($res, 'mysqli_fetch_object_construct', array('a')); + if (($obj->ID !== "4") || ($obj->label !== "d") || ($obj->a !== 'a') || ($obj->b !== NULL) || (get_class($obj) != 'mysqli_fetch_object_construct')) { + printf("[007] Object seems wrong. [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + var_dump($obj); + } + } catch (Throwable $e) { + echo "Exception: " . $e->getMessage() . "\n"; + } $obj = mysqli_fetch_object($res, 'mysqli_fetch_object_construct', array('a', 'b')); if (($obj->ID !== "5") || ($obj->label !== "e") || ($obj->a !== 'a') || ($obj->b !== 'b') || (get_class($obj) != 'mysqli_fetch_object_construct')) { @@ -140,12 +147,8 @@ require_once('skipifconnectfailure.inc'); --EXPECTF-- [E_WARNING] mysqli_fetch_object() expects at least 1 parameter, 0 given in %s on line %d [E_WARNING] mysqli_fetch_object() expects parameter 1 to be mysqli_result, null given in %s on line %d -[E_WARNING] Missing argument 1 for mysqli_fetch_object_construct::__construct() in %s on line %d -[E_WARNING] Missing argument 2 for mysqli_fetch_object_construct::__construct() in %s on line %d -[E_NOTICE] Undefined variable: a in %s on line %d -[E_NOTICE] Undefined variable: b in %s on line %d -[E_WARNING] Missing argument 2 for mysqli_fetch_object_construct::__construct() in %s on line %d -[E_NOTICE] Undefined variable: b in %s on line %d +Exception: Too few arguments to function mysqli_fetch_object_construct::__construct(), 0 passed and exactly 2 expected +Exception: Too few arguments to function mysqli_fetch_object_construct::__construct(), 1 passed and exactly 2 expected NULL NULL [E_WARNING] mysqli_fetch_object(): Couldn't fetch mysqli_result in %s on line %d diff --git a/ext/mysqli/tests/mysqli_fetch_object_oo.phpt b/ext/mysqli/tests/mysqli_fetch_object_oo.phpt index 82e311cc72..8fac044139 100644 --- a/ext/mysqli/tests/mysqli_fetch_object_oo.phpt +++ b/ext/mysqli/tests/mysqli_fetch_object_oo.phpt @@ -89,10 +89,14 @@ require_once('skipifconnectfailure.inc'); mysqli_fetch_object($res); } - $obj = $res->fetch_object('mysqli_fetch_object_construct', array('a')); - if (($obj->ID !== "4") || ($obj->label !== "d") || ($obj->a !== 'a') || ($obj->b !== NULL) || (get_class($obj) != 'mysqli_fetch_object_construct')) { - printf("[010] Object seems wrong. [%d] %s\n", $mysqli->errno, $mysqli->error); - var_dump($obj); + try { + $obj = $res->fetch_object('mysqli_fetch_object_construct', array('a')); + if (($obj->ID !== "4") || ($obj->label !== "d") || ($obj->a !== 'a') || ($obj->b !== NULL) || (get_class($obj) != 'mysqli_fetch_object_construct')) { + printf("[010] Object seems wrong. [%d] %s\n", $mysqli->errno, $mysqli->error); + var_dump($obj); + } + } catch (Throwable $e) { + echo "Exception: " . $e->getMessage() . "\n"; } $obj = $res->fetch_object('mysqli_fetch_object_construct', array('a', 'b')); @@ -132,8 +136,7 @@ require_once('skipifconnectfailure.inc'); [0] Argument 2 passed to mysqli_result::fetch_object() must be of the type array, object given in %s on line %d [0] Argument 2 passed to mysqli_result::fetch_object() must be of the type array, object given in %s on line %d [0] Argument 2 passed to mysqli_result::fetch_object() must be of the type array, null given in %s on line %d -[E_WARNING] Missing argument 2 for mysqli_fetch_object_construct::__construct() in %s on line %d -[E_NOTICE] Undefined variable: b in %s on line %d +Exception: Too few arguments to function mysqli_fetch_object_construct::__construct(), 1 passed and exactly 2 expected NULL NULL [E_WARNING] mysqli_fetch_object(): Couldn't fetch mysqli_result in %s on line %d diff --git a/ext/mysqli/tests/mysqli_get_client_stats.phpt b/ext/mysqli/tests/mysqli_get_client_stats.phpt index f0c4129dee..3e80c78e74 100644 --- a/ext/mysqli/tests/mysqli_get_client_stats.phpt +++ b/ext/mysqli/tests/mysqli_get_client_stats.phpt @@ -958,7 +958,7 @@ if (!mysqli_query($link, "DROP SERVER IF EXISTS myself")) mysqli_close($link); ?> --EXPECTF-- -array(161) { +array(163) { [%u|b%"bytes_sent"]=> %unicode|string%(1) "0" [%u|b%"bytes_received"]=> @@ -1125,10 +1125,14 @@ array(161) { %unicode|string%(1) "0" [%u|b%"mem_strndup_count"]=> %unicode|string%(1) "0" - [%u|b%"mem_estndup_count"]=> + [%u|b%"mem_estrdup_count"]=> %unicode|string%(1) "0" [%u|b%"mem_strdup_count"]=> %unicode|string%(1) "0" + [%u|b%"mem_edupl_count"]=> + %unicode|string%(1) "0" + [%u|b%"mem_dupl_count"]=> + %unicode|string%(1) "0" [%u|b%"proto_text_fetched_null"]=> %unicode|string%(1) "0" [%u|b%"proto_text_fetched_bit"]=> |