diff --git a/NEWS b/NEWS index 0265ad778095..e44eae1fae80 100644 --- a/NEWS +++ b/NEWS @@ -95,7 +95,9 @@ PHP NEWS . Passing objects to mb_convert_variables() is now deprecated. (Girgias) - MySQLi: - . The mysqli_get_charset() function is now deprecated. (Kamil Tekiela) + . The mysqli_get_charset() function and mysqli::get_charset() method are now deprecated. (Kamil Tekiela) + . The mysqli_stmt_init() function and mysqli::stmt_init() method are now deprecated. (Kamil Tekiela) + . Instantiation of mysqli_stmt without providing the $query parameter is now deprecated. (Kamil Tekiela) - PDO: . Fixed pdo_raise_impl_error() emitting a warning under ERRMODE_SILENT. diff --git a/UPGRADING b/UPGRADING index 271238bf404d..5d1f69f63b58 100644 --- a/UPGRADING +++ b/UPGRADING @@ -476,8 +476,11 @@ PHP 8.6 UPGRADE NOTES RFC: https://wiki.php.net/rfc/deprecations_php_8_6#passing_objects_for_vars_parameter_of_mb_convert_variables - MySQLi: - . The mysqli_get_charset() function is now deprecated. + . The mysqli_get_charset() function and mysqli::get_charset() method are now deprecated. RFC: https://wiki.php.net/rfc/deprecations_php_8_6#deprecate_mysqli_get_charset + . The mysqli_stmt_init() function, mysqli::stmt_init() method, and calling mysqli_stmt constructor + without providing the $query parameter are now deprecated. + RFC: https://wiki.php.net/rfc/deprecations_php_8_6#deprecate_mysqlistmt_init - Reflection: . Calling ReflectionProperty::setValue() with an object that is not an diff --git a/Zend/tests/partial_application/const_arg_opt_002.phpt b/Zend/tests/partial_application/const_arg_opt_002.phpt new file mode 100644 index 000000000000..5f3351276673 --- /dev/null +++ b/Zend/tests/partial_application/const_arg_opt_002.phpt @@ -0,0 +1,42 @@ +--TEST-- +Constant argument optimization - strict_types bug +--CREDITS-- +Ryan @ Calif.io +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.optimization_level=-1 +opcache.file_update_protection=0 +--FILE-- +getMessage(), "\n"; +} + +if (isset($partial)) { + try { + $partial(null); + } catch (Throwable $e) { + echo 'CALL: ', get_class($e), ': ', $e->getMessage(), "\n"; + } +} + +?> +--EXPECT-- +CREATE: TypeError: cand_86014_typed(): Argument #1 ($bound) must be of type int, string given diff --git a/Zend/tests/partial_application/const_arg_opt_003.phpt b/Zend/tests/partial_application/const_arg_opt_003.phpt new file mode 100644 index 000000000000..0841bff9e6f0 --- /dev/null +++ b/Zend/tests/partial_application/const_arg_opt_003.phpt @@ -0,0 +1,32 @@ +--TEST-- +Constant argument optimization - strict_types +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.optimization_level=-1 +opcache.file_update_protection=0 +--FILE-- +getClosureUsedVariables(); +if ($usedVars !== []) { + echo "const arg optimization was not applied\n"; + var_dump($usedVars); + exit; +} + +var_dump($f(0)); + +// Actual test. Not catching this as it disables optimizations +f("3", ?)(0); + +?> +--EXPECTF-- +int(3) + +Fatal error: Uncaught TypeError: f(): Argument #1 ($a) must be of type int, string given in %a diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c index 91f690c73ed0..4aa467315907 100644 --- a/Zend/zend_closures.c +++ b/Zend/zend_closures.c @@ -35,7 +35,7 @@ typedef struct _zend_closure { zend_object std; zend_function func; - zval this_ptr; + zend_object *this_ptr; zend_class_entry *called_scope; zif_handler orig_internal_handler; } zend_closure; @@ -45,7 +45,7 @@ ZEND_API zend_class_entry *zend_ce_closure; static zend_object_handlers closure_handlers; static zend_result zend_closure_get_closure(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr, bool check_only); -static void zend_create_closure_ex(zval *res, zend_function *func, zend_class_entry *scope, zend_class_entry *called_scope, zval *this_ptr, bool is_fake, uint32_t flags); +static void zend_create_closure_ex(zval *res, zend_function *func, zend_class_entry *scope, zend_class_entry *called_scope, zend_object *this_ptr, bool is_fake, uint32_t flags); static inline uint32_t zend_closure_flags(const zend_closure *closure) { @@ -90,32 +90,32 @@ ZEND_METHOD(Closure, __invoke) /* {{{ */ /* }}} */ static bool zend_valid_closure_binding( - zend_closure *closure, zval *newthis, zend_class_entry *scope) /* {{{ */ + zend_closure *closure, zend_object *new_this, zend_class_entry *scope) /* {{{ */ { zend_function *func = &closure->func; // TODO: rename variable bool is_fake_closure = (func->common.fn_flags & ZEND_ACC_FAKE_CLOSURE) != 0 || (closure->std.extra_flags & ZEND_PARTIAL); - if (newthis) { + if (new_this) { if (func->common.fn_flags & ZEND_ACC_STATIC) { zend_error(E_WARNING, "Cannot bind an instance to a static closure, this will be an error in PHP 9"); return false; } if (is_fake_closure && func->common.scope && - !instanceof_function(Z_OBJCE_P(newthis), func->common.scope)) { + !instanceof_function(new_this->ce, func->common.scope)) { /* Binding incompatible $this to an internal method is not supported. */ zend_error(E_WARNING, "Cannot bind method %s::%s() to object of class %s, this will be an error in PHP 9", ZSTR_VAL(func->common.scope->name), ZSTR_VAL(func->common.function_name), - ZSTR_VAL(Z_OBJCE_P(newthis)->name)); + ZSTR_VAL(new_this->ce->name)); return false; } } else if (is_fake_closure && func->common.scope && !(func->common.fn_flags & ZEND_ACC_STATIC)) { zend_error(E_WARNING, "Cannot unbind $this of method, this will be an error in PHP 9"); return false; - } else if (!is_fake_closure && !Z_ISUNDEF(closure->this_ptr) + } else if (!is_fake_closure && closure->this_ptr && (func->common.fn_flags & ZEND_ACC_USES_THIS)) { zend_error(E_WARNING, "Cannot unbind $this of closure using $this, this will be an error in PHP 9"); return false; @@ -144,32 +144,31 @@ static bool zend_valid_closure_binding( /* {{{ Call closure, binding to a given object with its class as the scope */ ZEND_METHOD(Closure, call) { - zval *newthis, closure_result; + zval closure_result; zend_closure *closure; zend_fcall_info fci; zend_fcall_info_cache fci_cache; - zend_object *newobj; + zend_object *new_this; zend_class_entry *newclass; fci.param_count = 0; fci.params = NULL; ZEND_PARSE_PARAMETERS_START(1, -1) - Z_PARAM_OBJECT(newthis) + Z_PARAM_OBJ(new_this) Z_PARAM_VARIADIC_WITH_NAMED(fci.params, fci.param_count, fci.named_params) ZEND_PARSE_PARAMETERS_END(); closure = (zend_closure *) Z_OBJ_P(ZEND_THIS); - newobj = Z_OBJ_P(newthis); - newclass = newobj->ce; + newclass = new_this->ce; - if (!zend_valid_closure_binding(closure, newthis, newclass)) { + if (!zend_valid_closure_binding(closure, new_this, newclass)) { return; } fci_cache.called_scope = newclass; - fci_cache.object = fci.object = newobj; + fci_cache.object = fci.object = new_this; fci.size = sizeof(fci); fci.consumed_args = 0; @@ -180,7 +179,7 @@ ZEND_METHOD(Closure, call) if (closure->func.common.fn_flags & ZEND_ACC_GENERATOR) { zval new_closure; zend_create_closure_ex(&new_closure, &closure->func, newclass, - closure->called_scope, newthis, + closure->called_scope, new_this, zend_closure_is_fake(closure), zend_closure_flags(closure)); closure = (zend_closure *) Z_OBJ(new_closure); fci_cache.function_handler = &closure->func; @@ -198,7 +197,7 @@ ZEND_METHOD(Closure, call) fake_closure->std.gc.refcount = 1; fake_closure->std.gc.u.type_info = GC_NULL; fake_closure->std.extra_flags = zend_closure_flags(closure); - ZVAL_UNDEF(&fake_closure->this_ptr); + fake_closure->this_ptr = NULL; fake_closure->called_scope = NULL; my_function = &fake_closure->func; if (ZEND_USER_CODE(closure->func.type)) { @@ -244,7 +243,7 @@ ZEND_METHOD(Closure, call) } /* }}} */ -static zend_result do_closure_bind(zval *return_value, zval *zclosure, zval *newthis, zend_object *scope_obj, zend_string *scope_str) +static zend_result do_closure_bind(zval *return_value, zval *zclosure, zend_object *new_this, zend_object *scope_obj, zend_string *scope_str) { zend_class_entry *ce, *called_scope; zend_closure *closure = (zend_closure *) Z_OBJ_P(zclosure); @@ -263,17 +262,17 @@ static zend_result do_closure_bind(zval *return_value, zval *zclosure, zval *new ce = NULL; } - if (!zend_valid_closure_binding(closure, newthis, ce)) { + if (!zend_valid_closure_binding(closure, new_this, ce)) { return FAILURE; } - if (newthis) { - called_scope = Z_OBJCE_P(newthis); + if (new_this) { + called_scope = new_this->ce; } else { called_scope = ce; } - zend_create_closure_ex(return_value, &closure->func, ce, called_scope, newthis, + zend_create_closure_ex(return_value, &closure->func, ce, called_scope, new_this, zend_closure_is_fake(closure), zend_closure_flags(closure)); if (zend_closure_flags(closure) & ZEND_PARTIAL_OF_CLOSURE) { @@ -286,7 +285,7 @@ static zend_result do_closure_bind(zval *return_value, zval *zclosure, zval *new ZEND_ASSERT(Z_TYPE_P(inner) == IS_OBJECT && Z_OBJCE_P(inner) == zend_ce_closure); zval new_inner; - if (do_closure_bind(&new_inner, inner, newthis, scope_obj, scope_str) != SUCCESS) { + if (do_closure_bind(&new_inner, inner, new_this, scope_obj, scope_str) != SUCCESS) { /* Should not happen, as we have already validated arguments and the * inner closure should have the same constraints. */ ZEND_UNREACHABLE(); @@ -306,34 +305,35 @@ static zend_result do_closure_bind(zval *return_value, zval *zclosure, zval *new /* {{{ Create a closure from another one and bind to another object and scope */ ZEND_METHOD(Closure, bind) { - zval *zclosure, *newthis; + zval *zclosure; + zend_object *new_this; zend_object *scope_obj = NULL; zend_string *scope_str = ZSTR_KNOWN(ZEND_STR_STATIC); ZEND_PARSE_PARAMETERS_START(2, 3) Z_PARAM_OBJECT_OF_CLASS(zclosure, zend_ce_closure) - Z_PARAM_OBJECT_OR_NULL(newthis) + Z_PARAM_OBJ_OR_NULL(new_this) Z_PARAM_OPTIONAL Z_PARAM_OBJ_OR_STR_OR_NULL(scope_obj, scope_str) ZEND_PARSE_PARAMETERS_END(); - do_closure_bind(return_value, zclosure, newthis, scope_obj, scope_str); + do_closure_bind(return_value, zclosure, new_this, scope_obj, scope_str); } /* {{{ Create a closure from another one and bind to another object and scope */ ZEND_METHOD(Closure, bindTo) { - zval *newthis; + zend_object *new_this; zend_object *scope_obj = NULL; zend_string *scope_str = ZSTR_KNOWN(ZEND_STR_STATIC); ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_OBJECT_OR_NULL(newthis) + Z_PARAM_OBJ_OR_NULL(new_this) Z_PARAM_OPTIONAL Z_PARAM_OBJ_OR_STR_OR_NULL(scope_obj, scope_str) ZEND_PARSE_PARAMETERS_END(); - do_closure_bind(return_value, ZEND_THIS, newthis, scope_obj, scope_str); + do_closure_bind(return_value, ZEND_THIS, new_this, scope_obj, scope_str); } static void zend_copy_parameters_array(const uint32_t param_count, HashTable *argument_array) /* {{{ */ @@ -396,7 +396,6 @@ static ZEND_NAMED_FUNCTION(zend_closure_call_magic) /* {{{ */ { static zend_result zend_create_closure_from_callable(zval *return_value, zval *callable, char **error) /* {{{ */ { zend_fcall_info_cache fcc; zend_function *mptr; - zval instance; zend_internal_function call; if (!zend_is_callable_ex(callable, NULL, 0, NULL, &fcc, error)) { @@ -439,12 +438,7 @@ static zend_result zend_create_closure_from_callable(zval *return_value, zval *c mptr = (zend_function *) &call; } - if (fcc.object) { - ZVAL_OBJ(&instance, fcc.object); - zend_create_fake_closure(return_value, mptr, mptr->common.scope, fcc.called_scope, &instance); - } else { - zend_create_fake_closure(return_value, mptr, mptr->common.scope, fcc.called_scope, NULL); - } + zend_create_fake_closure(return_value, mptr, mptr->common.scope, fcc.called_scope, fcc.object); if (&mptr->internal_function == &call) { zend_string_release(mptr->common.function_name); @@ -516,11 +510,7 @@ static int zend_closure_compare(zval *o1, zval *o2) /* {{{ */ return ZEND_UNCOMPARABLE; } - if (Z_TYPE(lhs->this_ptr) != Z_TYPE(rhs->this_ptr)) { - return ZEND_UNCOMPARABLE; - } - - if (Z_TYPE(lhs->this_ptr) == IS_OBJECT && Z_OBJ(lhs->this_ptr) != Z_OBJ(rhs->this_ptr)) { + if (lhs->this_ptr != rhs->this_ptr) { return ZEND_UNCOMPARABLE; } @@ -580,10 +570,10 @@ ZEND_API const zend_function *zend_get_closure_method_def(zend_object *obj) /* { } /* }}} */ -ZEND_API zval* zend_get_closure_this_ptr(zval *obj) /* {{{ */ +ZEND_API zend_object* zend_get_closure_this_ptr(zval *obj) /* {{{ */ { zend_closure *closure = (zend_closure *)Z_OBJ_P(obj); - return &closure->this_ptr; + return closure->this_ptr; } /* }}} */ @@ -613,8 +603,8 @@ static void zend_closure_free_storage(zend_object *object) /* {{{ */ zend_string_release(closure->func.common.function_name); } - if (Z_TYPE(closure->this_ptr) != IS_UNDEF) { - zval_ptr_dtor(&closure->this_ptr); + if (closure->this_ptr) { + OBJ_RELEASE(closure->this_ptr); } } /* }}} */ @@ -638,7 +628,8 @@ static zend_object *zend_closure_clone(zend_object *zobject) /* {{{ */ zval result; zend_create_closure_ex(&result, &closure->func, - closure->func.common.scope, closure->called_scope, &closure->this_ptr, + closure->func.common.scope, closure->called_scope, + closure->this_ptr, zend_closure_is_fake(closure), zend_closure_flags(closure)); return Z_OBJ(result); } @@ -650,12 +641,7 @@ static zend_result zend_closure_get_closure(zend_object *obj, zend_class_entry * *fptr_ptr = &closure->func; *ce_ptr = closure->called_scope; - - if (Z_TYPE(closure->this_ptr) != IS_UNDEF) { - *obj_ptr = Z_OBJ(closure->this_ptr); - } else { - *obj_ptr = NULL; - } + *obj_ptr = closure->this_ptr; return SUCCESS; } @@ -723,9 +709,10 @@ static HashTable *zend_closure_get_debug_info(zend_object *object, int *is_temp) } } - if (Z_TYPE(closure->this_ptr) != IS_UNDEF) { - Z_ADDREF(closure->this_ptr); - zend_hash_update(debug_info, ZSTR_KNOWN(ZEND_STR_THIS), &closure->this_ptr); + if (closure->this_ptr) { + zval tmp; + ZVAL_OBJ_COPY(&tmp, closure->this_ptr); + zend_hash_update(debug_info, ZSTR_KNOWN(ZEND_STR_THIS), &tmp); } if (arg_info && @@ -762,8 +749,15 @@ static HashTable *zend_closure_get_gc(zend_object *obj, zval **table, int *n) /* { zend_closure *closure = (zend_closure *)obj; - *table = Z_TYPE(closure->this_ptr) != IS_NULL ? &closure->this_ptr : NULL; - *n = Z_TYPE(closure->this_ptr) != IS_NULL ? 1 : 0; + if (closure->this_ptr) { + zend_get_gc_buffer *gc_buffer = zend_get_gc_buffer_create(); + zend_get_gc_buffer_add_obj(gc_buffer, closure->this_ptr); + zend_get_gc_buffer_use(gc_buffer, table, n); + } else { + *table = NULL; + *n = 0; + } + /* Fake closures don't own the static variables they reference. */ return (closure->func.type == ZEND_USER_FUNCTION && !(closure->func.op_array.fn_flags & ZEND_ACC_FAKE_CLOSURE)) ? @@ -807,7 +801,10 @@ static ZEND_NAMED_FUNCTION(zend_closure_internal_handler) /* {{{ */ } /* }}} */ -static void zend_create_closure_ex(zval *res, zend_function *func, zend_class_entry *scope, zend_class_entry *called_scope, zval *this_ptr, bool is_fake, uint32_t flags) /* {{{ */ +static void zend_create_closure_ex( + zval *res, zend_function *func, + zend_class_entry *scope, zend_class_entry *called_scope, + zend_object *this_ptr, bool is_fake, uint32_t flags) /* {{{ */ { zend_closure *closure; void *ptr; @@ -817,7 +814,7 @@ static void zend_create_closure_ex(zval *res, zend_function *func, zend_class_en closure = (zend_closure *)Z_OBJ_P(res); closure->std.extra_flags = flags; - if ((scope == NULL) && this_ptr && (Z_TYPE_P(this_ptr) != IS_UNDEF)) { + if ((scope == NULL) && this_ptr) { /* use dummy scope if we're binding an object without specifying a scope */ /* maybe it would be better to create one for this purpose */ scope = zend_ce_closure; @@ -896,28 +893,29 @@ static void zend_create_closure_ex(zval *res, zend_function *func, zend_class_en } } - ZVAL_UNDEF(&closure->this_ptr); + closure->this_ptr = NULL; /* Invariant: * If the closure is unscoped or static, it has no bound object. */ closure->func.common.scope = scope; closure->called_scope = called_scope; if (scope) { closure->func.common.fn_flags |= ZEND_ACC_PUBLIC; - if (this_ptr && Z_TYPE_P(this_ptr) == IS_OBJECT && (closure->func.common.fn_flags & ZEND_ACC_STATIC) == 0) { - ZVAL_OBJ_COPY(&closure->this_ptr, Z_OBJ_P(this_ptr)); + if (this_ptr && (closure->func.common.fn_flags & ZEND_ACC_STATIC) == 0) { + closure->this_ptr = this_ptr; + GC_ADDREF(this_ptr); } } } /* }}} */ -ZEND_API void zend_create_closure(zval *res, zend_function *func, zend_class_entry *scope, zend_class_entry *called_scope, zval *this_ptr) +ZEND_API void zend_create_closure(zval *res, zend_function *func, zend_class_entry *scope, zend_class_entry *called_scope, zend_object *this_ptr) { zend_create_closure_ex(res, func, scope, called_scope, this_ptr, /* is_fake */ (func->common.fn_flags & ZEND_ACC_FAKE_CLOSURE) != 0, /* flags */ 0); } -ZEND_API void zend_create_fake_closure(zval *res, zend_function *func, zend_class_entry *scope, zend_class_entry *called_scope, zval *this_ptr) /* {{{ */ +ZEND_API void zend_create_fake_closure(zval *res, zend_function *func, zend_class_entry *scope, zend_class_entry *called_scope, zend_object *this_ptr) /* {{{ */ { zend_closure *closure; @@ -926,13 +924,13 @@ ZEND_API void zend_create_fake_closure(zval *res, zend_function *func, zend_clas closure = (zend_closure *)Z_OBJ_P(res); closure->func.common.fn_flags |= ZEND_ACC_FAKE_CLOSURE; - if (Z_TYPE(closure->this_ptr) != IS_OBJECT) { + if (!closure->this_ptr) { GC_ADD_FLAGS(&closure->std, GC_NOT_COLLECTABLE); } } /* }}} */ -ZEND_API void zend_create_partial_closure(zval *res, zend_function *func, zend_class_entry *scope, zend_class_entry *called_scope, zval *this_ptr, bool partial_of_closure) +ZEND_API void zend_create_partial_closure(zval *res, zend_function *func, zend_class_entry *scope, zend_class_entry *called_scope, zend_object *this_ptr, bool partial_of_closure) { uint32_t flags = ZEND_PARTIAL; if (partial_of_closure) { @@ -943,7 +941,6 @@ ZEND_API void zend_create_partial_closure(zval *res, zend_function *func, zend_c } void zend_closure_from_frame(zval *return_value, const zend_execute_data *call) { /* {{{ */ - zval instance; zend_internal_function trampoline; zend_function *mptr = call->func; @@ -974,9 +971,7 @@ void zend_closure_from_frame(zval *return_value, const zend_execute_data *call) } if (ZEND_CALL_INFO(call) & ZEND_CALL_HAS_THIS) { - ZVAL_OBJ(&instance, Z_OBJ(call->This)); - - zend_create_fake_closure(return_value, mptr, mptr->common.scope, Z_OBJCE(instance), &instance); + zend_create_fake_closure(return_value, mptr, mptr->common.scope, Z_OBJCE(call->This), Z_OBJ(call->This)); } else { zend_create_fake_closure(return_value, mptr, mptr->common.scope, Z_CE(call->This), NULL); } diff --git a/Zend/zend_closures.h b/Zend/zend_closures.h index 305d82e5015a..c421c100833a 100644 --- a/Zend/zend_closures.h +++ b/Zend/zend_closures.h @@ -34,12 +34,12 @@ void zend_closure_from_frame(zval *closure_zv, const zend_execute_data *frame); extern ZEND_API zend_class_entry *zend_ce_closure; -ZEND_API void zend_create_closure(zval *res, zend_function *op_array, zend_class_entry *scope, zend_class_entry *called_scope, zval *this_ptr); -ZEND_API void zend_create_fake_closure(zval *res, zend_function *op_array, zend_class_entry *scope, zend_class_entry *called_scope, zval *this_ptr); -ZEND_API void zend_create_partial_closure(zval *res, zend_function *func, zend_class_entry *scope, zend_class_entry *called_scope, zval *this_ptr, bool partial_of_closure); +ZEND_API void zend_create_closure(zval *res, zend_function *op_array, zend_class_entry *scope, zend_class_entry *called_scope, zend_object *this_ptr); +ZEND_API void zend_create_fake_closure(zval *res, zend_function *op_array, zend_class_entry *scope, zend_class_entry *called_scope, zend_object *this_ptr); +ZEND_API void zend_create_partial_closure(zval *res, zend_function *func, zend_class_entry *scope, zend_class_entry *called_scope, zend_object *this_ptr, bool partial_of_closure); ZEND_API zend_function *zend_get_closure_invoke_method(zend_object *obj); ZEND_API const zend_function *zend_get_closure_method_def(zend_object *obj); -ZEND_API zval* zend_get_closure_this_ptr(zval *obj); +ZEND_API zend_object* zend_get_closure_this_ptr(zval *obj); END_EXTERN_C() diff --git a/Zend/zend_partial.c b/Zend/zend_partial.c index ec60383a2bc8..ce1604ddc67a 100644 --- a/Zend/zend_partial.c +++ b/Zend/zend_partial.c @@ -561,6 +561,30 @@ static zend_ast *zp_compile_forwarding_call( args_ast = zend_ast_list_add(args_ast, default_value_ast); } else if (zp_is_const_arg(const_args, offset)) { ZEND_ASSERT(Z_TYPE(argv[offset]) < IS_OBJECT); + + /* This argument never changes, so we can burn it into the op_array + * and check its type ahead of time. */ + + zend_arg_info *arg_info; + if (offset < function->common.num_args) { + arg_info = &function->common.arg_info[offset]; + } else if (function->common.fn_flags & ZEND_ACC_VARIADIC) { + arg_info = &function->common.arg_info[function->common.num_args]; + } else { + arg_info = NULL; + } + if (arg_info && ZEND_TYPE_IS_SET(arg_info->type) + && UNEXPECTED(!zend_check_type_ex(&arg_info->type, &argv[offset], + /* current_frame */ true, /* is_internal */ false))) { + zend_string *need_msg = zend_type_to_string_resolved(arg_info->type, + function->common.scope); + zend_argument_type_error_ex(function, offset + 1, + "must be of type %s, %s given", + ZSTR_VAL(need_msg), zend_zval_value_name(&argv[offset])); + zend_string_release(need_msg); + goto error; + } + args_ast = zend_ast_list_add(args_ast, zend_ast_create_zval(&argv[offset])); } else { args_ast = zend_ast_list_add(args_ast, zend_ast_create(ZEND_AST_VAR, @@ -1125,7 +1149,7 @@ void zend_partial_create(zval *result, zval *this_ptr, zend_function *function, } zend_class_entry *called_scope; - zval object; + zend_object *object; if (Z_TYPE_P(this_ptr) == IS_OBJECT) { called_scope = Z_OBJCE_P(this_ptr); @@ -1134,13 +1158,13 @@ void zend_partial_create(zval *result, zval *this_ptr, zend_function *function, } if (Z_TYPE_P(this_ptr) == IS_OBJECT && !zp_is_static_closure(function)) { - ZVAL_COPY_VALUE(&object, this_ptr); + object = Z_OBJ_P(this_ptr); } else { - ZVAL_UNDEF(&object); + object = NULL; } zend_create_partial_closure(result, (zend_function*)op_array, - function->common.scope, called_scope, &object, + function->common.scope, called_scope, object, (function->common.fn_flags & ZEND_ACC_CLOSURE) != 0); zp_bind(result, function, argc, argv, extra_named_params, const_args); diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index cf8072646ee4..01131b5d3ae0 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -8413,7 +8413,7 @@ ZEND_VM_HANDLER(142, ZEND_DECLARE_LAMBDA_FUNCTION, UNUSED, NUM, NUM|CACHE_SLOT) { USE_OPLINE zend_function *func; - zval *object; + zend_object *object; zend_class_entry *called_scope; if (opline->extended_value != (uint32_t)-1) { @@ -8431,7 +8431,7 @@ ZEND_VM_HANDLER(142, ZEND_DECLARE_LAMBDA_FUNCTION, UNUSED, NUM, NUM|CACHE_SLOT) (EX(func)->common.fn_flags & ZEND_ACC_STATIC))) { object = NULL; } else { - object = &EX(This); + object = Z_OBJ(EX(This)); } } else { called_scope = Z_CE(EX(This)); diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 58cd0ddf916e..5061d772ee82 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -32905,7 +32905,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_DECLARE_LAMBD { USE_OPLINE zend_function *func; - zval *object; + zend_object *object; zend_class_entry *called_scope; if (opline->extended_value != (uint32_t)-1) { @@ -32923,7 +32923,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_DECLARE_LAMBD (EX(func)->common.fn_flags & ZEND_ACC_STATIC))) { object = NULL; } else { - object = &EX(This); + object = Z_OBJ(EX(This)); } } else { called_scope = Z_CE(EX(This)); @@ -85548,7 +85548,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_DECLARE_LAMBDA_FUN { USE_OPLINE zend_function *func; - zval *object; + zend_object *object; zend_class_entry *called_scope; if (opline->extended_value != (uint32_t)-1) { @@ -85566,7 +85566,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_DECLARE_LAMBDA_FUN (EX(func)->common.fn_flags & ZEND_ACC_STATIC))) { object = NULL; } else { - object = &EX(This); + object = Z_OBJ(EX(This)); } } else { called_scope = Z_CE(EX(This)); diff --git a/ext/gd/config.m4 b/ext/gd/config.m4 index 17f508be2a9a..070cc158fef3 100644 --- a/ext/gd/config.m4 +++ b/ext/gd/config.m4 @@ -394,13 +394,31 @@ if test "$PHP_GD" != "no"; then AC_DEFINE([HAVE_GD_PNG_GET_VERSION_STRING], [1], [Define to 1 if GD library has the 'gdPngGetVersionString' function.]) - dnl Some systems (e.g. Solaris) declare iconv_t in as something - dnl other than 'void *'. The bundled libgd/gdkanji.c only falls back to its - dnl own 'typedef void *iconv_t' when HAVE_ICONV_T_DEF is undefined, so detect - dnl the system definition to avoid a conflicting typedef. - AC_EGREP_HEADER([typedef.*iconv_t], [iconv.h], - [AC_DEFINE([HAVE_ICONV_T_DEF], [1], - [Define to 1 if defines iconv_t.])]) + dnl The bundled libgd/gdkanji.c includes only when HAVE_ICONV_H or + dnl HAVE_ICONV is defined, and skips its own 'typedef void *iconv_t' when + dnl HAVE_ICONV_T_DEF is defined. HAVE_ICONV comes from the iconv extension, + dnl which needn't be part of this build, so detect iconv here and define the + dnl typedef macro only along with the header one. + AC_CACHE_CHECK([for iconv usable by the gd extension], [php_cv_lib_gd_iconv], + [php_cv_lib_gd_iconv=no + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], + [[iconv_t cd = iconv_open("", ""); (void)iconv_close(cd);]])], + [php_cv_lib_gd_iconv=yes], + [LIBS_SAVED=$LIBS + LIBS="-liconv $LIBS" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], + [[iconv_t cd = iconv_open("", ""); (void)iconv_close(cd);]])], + [php_cv_lib_gd_iconv=-liconv]) + LIBS=$LIBS_SAVED])]) + AS_VAR_IF([php_cv_lib_gd_iconv], [no],, [ + AS_VAR_IF([php_cv_lib_gd_iconv], [-liconv], + [PHP_ADD_LIBRARY([iconv], [1], [GD_SHARED_LIBADD])]) + AC_DEFINE([HAVE_ICONV_H], [1], + [Define to 1 if you have the header file.]) + AC_EGREP_HEADER([typedef.*iconv_t], [iconv.h], + [AC_DEFINE([HAVE_ICONV_T_DEF], [1], + [Define to 1 if defines iconv_t.])]) + ]) dnl Various checks for GD features PHP_SETUP_ZLIB([GD_SHARED_LIBADD]) diff --git a/ext/gd/tests/avif_decode_encode.phpt b/ext/gd/tests/avif_decode_encode.phpt index 054eb5246763..d412309bc18e 100644 --- a/ext/gd/tests/avif_decode_encode.phpt +++ b/ext/gd/tests/avif_decode_encode.phpt @@ -39,7 +39,7 @@ gd try { imageavif($img, $outfile, 1234); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } echo 'Encoding AVIF with illegal speed: '; @@ -47,7 +47,7 @@ gd try { imageavif($img, $outfile, 70, 1234); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } echo 'Encoding AVIF losslessly... '; @@ -75,8 +75,8 @@ Default AVIF encoding: ok Encoding AVIF at quality 70: ok Encoding AVIF at quality 70 with speed 5: ok Encoding AVIF with default quality: ok -Encoding AVIF with illegal quality: imageavif(): Argument #3 ($quality) must be between -1 and 100 -Encoding AVIF with illegal speed: imageavif(): Argument #4 ($speed) must be between -1 and 10 +Encoding AVIF with illegal quality: ValueError: imageavif(): Argument #3 ($quality) must be between -1 and 100 +Encoding AVIF with illegal speed: ValueError: imageavif(): Argument #4 ($speed) must be between -1 and 10 Encoding AVIF losslessly... ok Decoding the AVIF we just wrote... What is the mean squared error of the two images? 0 diff --git a/ext/gd/tests/bug66356.phpt b/ext/gd/tests/bug66356.phpt index 616a270115c1..b82eb03958d5 100644 --- a/ext/gd/tests/bug66356.phpt +++ b/ext/gd/tests/bug66356.phpt @@ -13,7 +13,7 @@ $arr = array("x" => 2147483647, "y" => 2147483647, "width" => 10, "height" => 10 try { imagecrop($img, $arr); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } print_r($arr); @@ -32,7 +32,7 @@ var_dump(imagecrop($img, array("x" => 0, "y" => 0, "width" => 65535, "height" => --EXPECTF-- object(GdImage)#2 (0) { } -imagecrop(): Argument #2 ($rectangle) overflow with "x" and "width" keys +ValueError: imagecrop(): Argument #2 ($rectangle) overflow with "x" and "width" keys Array ( [x] => 2147483647 diff --git a/ext/gd/tests/bug72337.phpt b/ext/gd/tests/bug72337.phpt index a15fa349304e..4973b39eb286 100644 --- a/ext/gd/tests/bug72337.phpt +++ b/ext/gd/tests/bug72337.phpt @@ -8,23 +8,23 @@ $im = imagecreatetruecolor(1, 1); try { imagescale($im, 1, 1, -10); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { imagescale($im, 0, 1, 0); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { imagescale($im, 1, 0, 0); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } imagescale($im, 1, 1, IMG_BICUBIC_FIXED); echo "OK"; ?> --EXPECT-- -imagescale(): Argument #4 ($mode) must be one of the GD_* constants -imagescale(): Argument #2 ($width) must be between 1 and 2147483647 -imagescale(): Argument #3 ($height) must be between 1 and 2147483647 +ValueError: imagescale(): Argument #4 ($mode) must be one of the GD_* constants +ValueError: imagescale(): Argument #2 ($width) must be between 1 and 2147483647 +ValueError: imagescale(): Argument #3 ($height) must be between 1 and 2147483647 OK diff --git a/ext/gd/tests/bug72709.phpt b/ext/gd/tests/bug72709.phpt index bc20d1bf58b8..7d9e34ecdabf 100644 --- a/ext/gd/tests/bug72709.phpt +++ b/ext/gd/tests/bug72709.phpt @@ -10,12 +10,12 @@ try { var_dump(imagesetstyle($im, array())); } catch (\Error $ex) { - echo $ex->getMessage() . "\n"; + echo $ex::class, ': ', $ex->getMessage(), "\n"; } imagesetpixel($im, 0, 0, IMG_COLOR_STYLED); ?> ====DONE==== --EXPECT-- -imagesetstyle(): Argument #2 ($style) must not be empty +ValueError: imagesetstyle(): Argument #2 ($style) must not be empty ====DONE==== diff --git a/ext/gd/tests/bug73957.phpt b/ext/gd/tests/bug73957.phpt index 067d71674eb2..986adafa0767 100644 --- a/ext/gd/tests/bug73957.phpt +++ b/ext/gd/tests/bug73957.phpt @@ -15,8 +15,8 @@ try { // which is not supposed to happen var_dump(imagesx($im)); } catch (\ValueError $e) { - echo $e->getMessage(); + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } ?> --EXPECTF-- -imagescale(): Argument #2 ($width) must be between 1 and %d +ValueError: imagescale(): Argument #2 ($width) must be between 1 and %d diff --git a/ext/gd/tests/bug81739.phpt b/ext/gd/tests/bug81739.phpt index b340aa7c0758..c7f6a4054bf4 100644 --- a/ext/gd/tests/bug81739.phpt +++ b/ext/gd/tests/bug81739.phpt @@ -19,4 +19,4 @@ Warning: imageloadfont(): %croduct of memory allocation multiplication would exc in %s on line %d Warning: imageloadfont(): Error reading font, invalid font header in %s on line %d -bool(false) \ No newline at end of file +bool(false) diff --git a/ext/gd/tests/colorclosest.phpt b/ext/gd/tests/colorclosest.phpt index 8cfcbdcdea4e..2a1898304613 100644 --- a/ext/gd/tests/colorclosest.phpt +++ b/ext/gd/tests/colorclosest.phpt @@ -15,7 +15,7 @@ $c = imagecolorclosest($im, 255,0,255); try { imagecolorsforindex($im, $c); } catch (ValueError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } $im = null; @@ -53,7 +53,7 @@ $c = imagecolorclosestalpha($im, 255,0,255,100); try { imagecolorsforindex($im, $c); } catch (ValueError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } $im = null; @@ -82,7 +82,7 @@ print_r(imagecolorsforindex($im, $c)); ?> --EXPECT-- FF00FF -imagecolorsforindex(): Argument #2 ($color) is out of range +ValueError: imagecolorsforindex(): Argument #2 ($color) is out of range Array ( [red] => 255 @@ -105,7 +105,7 @@ Array [alpha] => 0 ) 64FF00FF -imagecolorsforindex(): Argument #2 ($color) is out of range +ValueError: imagecolorsforindex(): Argument #2 ($color) is out of range Array ( [red] => 255 diff --git a/ext/gd/tests/colormatch.phpt b/ext/gd/tests/colormatch.phpt index fe22784c9942..a2def011c481 100644 --- a/ext/gd/tests/colormatch.phpt +++ b/ext/gd/tests/colormatch.phpt @@ -11,11 +11,11 @@ $im2 = imagecreate(5,5); try { imagecolormatch($im, $im2); } catch (ValueError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } echo "ok\n"; ?> --EXPECT-- -imagecolormatch(): Argument #2 ($image2) must have at least one color +ValueError: imagecolormatch(): Argument #2 ($image2) must have at least one color ok diff --git a/ext/gd/tests/createfromstring.phpt b/ext/gd/tests/createfromstring.phpt index ce90b368f2e7..569fc0dd41be 100644 --- a/ext/gd/tests/createfromstring.phpt +++ b/ext/gd/tests/createfromstring.phpt @@ -55,7 +55,7 @@ unlink($dir . '/p.png'); try { imagecreatefromstring(''); } catch (ValueError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } //random string > 12 $im = imagecreatefromstring(' asdf jklp foo'); diff --git a/ext/gd/tests/gdimage_prevent_cloning.phpt b/ext/gd/tests/gdimage_prevent_cloning.phpt index 609e6f99bbfa..22a4120be0bc 100644 --- a/ext/gd/tests/gdimage_prevent_cloning.phpt +++ b/ext/gd/tests/gdimage_prevent_cloning.phpt @@ -9,7 +9,7 @@ try { $img_src = imagecreatetruecolor(32, 32); $img_dst = clone $img_src; } catch (Throwable $e) { - echo $e::class, ": ", $e->getMessage(), PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } ?> diff --git a/ext/gd/tests/gh16255.phpt b/ext/gd/tests/gh16255.phpt index 147dc5adf377..c255f1027e37 100644 --- a/ext/gd/tests/gh16255.phpt +++ b/ext/gd/tests/gh16255.phpt @@ -12,23 +12,23 @@ $im = imagecreatetruecolor(40, 40); try { imageconvolution($im, $matrix, NAN, 1.0); } catch (ValueError $e) { - echo $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } try { imageconvolution($im, $matrix, 2.225E-307, 1.0); } catch (ValueError $e) { - echo $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } try { imageconvolution($im, $matrix, 1, NAN); } catch (ValueError $e) { - echo $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- -imageconvolution(): Argument #3 ($divisor) must be finite -imageconvolution(): Argument #3 ($divisor) must not be 0 -imageconvolution(): Argument #4 ($offset) must be finite +ValueError: imageconvolution(): Argument #3 ($divisor) must be finite +ValueError: imageconvolution(): Argument #3 ($divisor) must not be 0 +ValueError: imageconvolution(): Argument #4 ($offset) must be finite diff --git a/ext/gd/tests/gh16260.phpt b/ext/gd/tests/gh16260.phpt index 563fc8d16278..57daf82b387d 100644 --- a/ext/gd/tests/gh16260.phpt +++ b/ext/gd/tests/gh16260.phpt @@ -9,14 +9,14 @@ $im = imagecreatetruecolor(10,10); try { imagerotate($im, PHP_INT_MIN, 0); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { imagerotate($im, PHP_INT_MAX, 0); } catch (\ValueError $e) { - echo $e->getMessage(); + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } --EXPECTF-- -imagerotate(): Argument #2 ($angle) must be between %s and %s -imagerotate(): Argument #2 ($angle) must be between %s and %s +ValueError: imagerotate(): Argument #2 ($angle) must be between %s and %s +ValueError: imagerotate(): Argument #2 ($angle) must be between %s and %s diff --git a/ext/gd/tests/gh16322.phpt b/ext/gd/tests/gh16322.phpt index 1e5ab2f3a6b1..abe6846b1726 100644 --- a/ext/gd/tests/gh16322.phpt +++ b/ext/gd/tests/gh16322.phpt @@ -10,16 +10,16 @@ $src = imagecreatetruecolor(8, 8); try { imageaffine($src, $matrix); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } $matrix[0] = 1; $matrix[3] = -INF; try { imageaffine($src, $matrix); } catch (\ValueError $e) { - echo $e->getMessage(); + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } ?> --EXPECTF-- -imageaffine(): Argument #2 ($affine) element 0 must be between %s and %d -imageaffine(): Argument #2 ($affine) element 3 must be between %s and %d +ValueError: imageaffine(): Argument #2 ($affine) element 0 must be between %s and %d +ValueError: imageaffine(): Argument #2 ($affine) element 3 must be between %s and %d diff --git a/ext/gd/tests/gh17703.phpt b/ext/gd/tests/gh17703.phpt index 4677b6a50139..9d9145f30e0c 100644 --- a/ext/gd/tests/gh17703.phpt +++ b/ext/gd/tests/gh17703.phpt @@ -10,8 +10,8 @@ $img = imagecreatetruecolor ( 256, 1); try { imagescale($img, -1, -1, 0); } catch (\ValueError $e) { - echo $e->getMessage(); + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } ?> --EXPECT-- -Argument #2 ($width) and argument #3 ($height) cannot be both negative +ValueError: Argument #2 ($width) and argument #3 ($height) cannot be both negative diff --git a/ext/gd/tests/gh18005.phpt b/ext/gd/tests/gh18005.phpt index 5282c0be0268..e36d2efa2cd6 100644 --- a/ext/gd/tests/gh18005.phpt +++ b/ext/gd/tests/gh18005.phpt @@ -13,80 +13,80 @@ $img = imagecreatetruecolor(1, 1); try { imagesetstyle($img, [0, new A()]); } catch (\TypeError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { imagesetstyle($img, [0, PHP_INT_MIN]); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { imagefilter($img, IMG_FILTER_SCATTER, 0, 0, [new A()]); } catch (\TypeError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { imagefilter($img, IMG_FILTER_SCATTER, 0, 0, [-1]); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { imagecrop($img, ["x" => PHP_INT_MIN, "y" => 0, "width" => 0, "height" => 0]); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { imagecrop($img, ["x" => 0, "y" => PHP_INT_MIN, "width" => 0, "height" => 0]); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { imagecrop($img, ["x" => 0, "y" => 0, "width" => PHP_INT_MAX, "height" => 0]); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { imagecrop($img, ["x" => 0, "y" => 0, "width" => 0, "height" => PHP_INT_MAX]); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { imagecrop($img, ["x" => new A(), "y" => 0, "width" => 0, "height" => 0]); } catch (\TypeError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { imagecrop($img, ["x" => 0, "y" => new A(), "width" => 0, "height" => 0]); } catch (\TypeError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { imagecrop($img, ["x" => 0, "y" => 0, "width" => new A(), "height" => 0]); } catch (\TypeError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { imagecrop($img, ["x" => 0, "y" => 0, "width" => 0, "height" => new A()]); } catch (\TypeError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } $one = 1; var_dump(imagecrop($img, ["x" => &$one, "y" => &$one, "width" => &$one, "height" => &$one])); ?> --EXPECTF-- -imagesetstyle(): Argument #2 ($style) must only have elements of type int, A given -imagesetstyle(): Argument #2 ($style) elements must be between %i and %d -imagefilter(): Argument #5 must be of type int, A given -imagefilter(): Argument #5 value must be between 0 and 2147483647 -imagecrop(): Argument #2 ($rectangle) "x" key must be between %i and %d -imagecrop(): Argument #2 ($rectangle) "y" key must be between %i and %d -imagecrop(): Argument #2 ($rectangle) "width" key must be between %i and %d -imagecrop(): Argument #2 ($rectangle) "height" key must be between %i and %d -imagecrop(): Argument #2 ($rectangle) "x" key must be of type int, A given -imagecrop(): Argument #2 ($rectangle) "y" key must be of type int, A given -imagecrop(): Argument #2 ($rectangle) "width" key must be of type int, A given -imagecrop(): Argument #2 ($rectangle) "height" key must be of type int, A given +TypeError: imagesetstyle(): Argument #2 ($style) must only have elements of type int, A given +ValueError: imagesetstyle(): Argument #2 ($style) elements must be between %i and %d +TypeError: imagefilter(): Argument #5 must be of type int, A given +ValueError: imagefilter(): Argument #5 value must be between 0 and 2147483647 +ValueError: imagecrop(): Argument #2 ($rectangle) "x" key must be between %i and %d +ValueError: imagecrop(): Argument #2 ($rectangle) "y" key must be between %i and %d +ValueError: imagecrop(): Argument #2 ($rectangle) "width" key must be between %i and %d +ValueError: imagecrop(): Argument #2 ($rectangle) "height" key must be between %i and %d +TypeError: imagecrop(): Argument #2 ($rectangle) "x" key must be of type int, A given +TypeError: imagecrop(): Argument #2 ($rectangle) "y" key must be of type int, A given +TypeError: imagecrop(): Argument #2 ($rectangle) "width" key must be of type int, A given +TypeError: imagecrop(): Argument #2 ($rectangle) "height" key must be of type int, A given object(GdImage)#2 (0) { } diff --git a/ext/gd/tests/gh18243.phpt b/ext/gd/tests/gh18243.phpt index 3235098a3dcc..00698add614c 100644 --- a/ext/gd/tests/gh18243.phpt +++ b/ext/gd/tests/gh18243.phpt @@ -14,29 +14,29 @@ $im = imagecreatetruecolor(100, 80); try { imagettftext($im, PHP_INT_MAX, 0, 15, 60, 0, $font, ""); } catch (\ValueError $e) { - echo $e->getMessage(), PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { imagettftext($im, PHP_INT_MIN, 0, 15, 60, 0, $font, ""); } catch (\ValueError $e) { - echo $e->getMessage(), PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { imagettftext($im, NAN, 0, 15, 60, 0, $font, ""); } catch (\ValueError $e) { - echo $e->getMessage(), PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { imagettftext($im, INF, 0, 15, 60, 0, $font, ""); } catch (\ValueError $e) { - echo $e->getMessage(); + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } ?> --EXPECTF-- -imagettftext(): Argument #2 ($size) must be between %i and %d -imagettftext(): Argument #2 ($size) must be between %i and %d -imagettftext(): Argument #2 ($size) must be finite -imagettftext(): Argument #2 ($size) must be between %i and %d +ValueError: imagettftext(): Argument #2 ($size) must be between %i and %d +ValueError: imagettftext(): Argument #2 ($size) must be between %i and %d +ValueError: imagettftext(): Argument #2 ($size) must be finite +ValueError: imagettftext(): Argument #2 ($size) must be between %i and %d diff --git a/ext/gd/tests/gh19578.phpt b/ext/gd/tests/gh19578.phpt index 15d10f752d0d..cc13c6467921 100644 --- a/ext/gd/tests/gh19578.phpt +++ b/ext/gd/tests/gh19578.phpt @@ -13,15 +13,15 @@ $src = imagecreatetruecolor(255, 255); try { imagefilledellipse($src, 0, 0, PHP_INT_MAX, 254, 0); } catch (\ValueError $e) { - echo $e->getMessage(), PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { imagefilledellipse($src, 0, 0, -16, 254, 0); } catch (\ValueError $e) { - echo $e->getMessage(); + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } ?> --EXPECTF-- -imagefilledellipse(): Argument #4 ($width) must be between 0 and %d -imagefilledellipse(): Argument #4 ($width) must be between 0 and %d +ValueError: imagefilledellipse(): Argument #4 ($width) must be between 0 and %d +ValueError: imagefilledellipse(): Argument #4 ($width) must be between 0 and %d diff --git a/ext/gd/tests/gh20551.phpt b/ext/gd/tests/gh20551.phpt index 32ca50ca5f62..04a62a256df2 100644 --- a/ext/gd/tests/gh20551.phpt +++ b/ext/gd/tests/gh20551.phpt @@ -21,16 +21,16 @@ foreach ($gammas as $gamma) { try { imagegammacorrect($im, $gamma[0], $gamma[1]); } catch (\ValueError $e) { - echo $e->getMessage(), PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } } ?> --EXPECT-- -imagegammacorrect(): Argument #2 ($input_gamma) must be finite -imagegammacorrect(): Argument #2 ($input_gamma) must be finite -imagegammacorrect(): Argument #2 ($input_gamma) must be finite -imagegammacorrect(): Argument #2 ($input_gamma) must be greater than 0 -imagegammacorrect(): Argument #3 ($output_gamma) must be finite -imagegammacorrect(): Argument #3 ($output_gamma) must be finite -imagegammacorrect(): Argument #3 ($output_gamma) must be finite -imagegammacorrect(): Argument #3 ($output_gamma) must be greater than 0 +ValueError: imagegammacorrect(): Argument #2 ($input_gamma) must be finite +ValueError: imagegammacorrect(): Argument #2 ($input_gamma) must be finite +ValueError: imagegammacorrect(): Argument #2 ($input_gamma) must be finite +ValueError: imagegammacorrect(): Argument #2 ($input_gamma) must be greater than 0 +ValueError: imagegammacorrect(): Argument #3 ($output_gamma) must be finite +ValueError: imagegammacorrect(): Argument #3 ($output_gamma) must be finite +ValueError: imagegammacorrect(): Argument #3 ($output_gamma) must be finite +ValueError: imagegammacorrect(): Argument #3 ($output_gamma) must be greater than 0 diff --git a/ext/gd/tests/gh20602.phpt b/ext/gd/tests/gh20602.phpt index 29c781e76a2d..b481b32ae9b6 100644 --- a/ext/gd/tests/gh20602.phpt +++ b/ext/gd/tests/gh20602.phpt @@ -9,14 +9,14 @@ $im = imagecreatetruecolor(16, 16); try { imagescale($im, PHP_INT_MAX, -1); } catch (\ValueError $e) { - echo $e->getMessage(), PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { imagescale($im, -1, PHP_INT_MAX); } catch (\ValueError $e) { - echo $e->getMessage(), PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } ?> --EXPECTF-- -imagescale(): Argument #2 ($width) must be less than or equal to %d -imagescale(): Argument #3 ($height) must be less than or equal to %d +ValueError: imagescale(): Argument #2 ($width) must be less than or equal to %d +ValueError: imagescale(): Argument #3 ($height) must be less than or equal to %d diff --git a/ext/gd/tests/gh8848.phpt b/ext/gd/tests/gh8848.phpt index 0e18b64babb3..324307f55966 100644 --- a/ext/gd/tests/gh8848.phpt +++ b/ext/gd/tests/gh8848.phpt @@ -18,12 +18,12 @@ foreach ($argslist as $args) { try { imagecopyresized($image1, $image2, 1, 1, 1, 1, ...$args); } catch (ValueError $ex) { - echo $ex->getMessage(), PHP_EOL; + echo $ex::class, ': ', $ex->getMessage(), PHP_EOL; } } ?> --EXPECT-- -imagecopyresized(): Argument #7 ($dst_width) must be greater than 0 -imagecopyresized(): Argument #8 ($dst_height) must be greater than 0 -imagecopyresized(): Argument #9 ($src_width) must be greater than 0 -imagecopyresized(): Argument #10 ($src_height) must be greater than 0 +ValueError: imagecopyresized(): Argument #7 ($dst_width) must be greater than 0 +ValueError: imagecopyresized(): Argument #8 ($dst_height) must be greater than 0 +ValueError: imagecopyresized(): Argument #9 ($src_width) must be greater than 0 +ValueError: imagecopyresized(): Argument #10 ($src_height) must be greater than 0 diff --git a/ext/gd/tests/imagebmp_nullbyte_injection.phpt b/ext/gd/tests/imagebmp_nullbyte_injection.phpt index 81a3e40d7c27..2fe4aa9b34eb 100644 --- a/ext/gd/tests/imagebmp_nullbyte_injection.phpt +++ b/ext/gd/tests/imagebmp_nullbyte_injection.phpt @@ -12,8 +12,8 @@ $image = imagecreate(1,1);// 1px image try { imagebmp($image, "./foo\0bar"); } catch (TypeError $e) { - echo $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- -imagebmp(): Argument #2 ($file) must not contain null bytes +TypeError: imagebmp(): Argument #2 ($file) must not contain null bytes diff --git a/ext/gd/tests/imagecolormatch_error2.phpt b/ext/gd/tests/imagecolormatch_error2.phpt index 5af039a785dd..c2cdc0b91580 100644 --- a/ext/gd/tests/imagecolormatch_error2.phpt +++ b/ext/gd/tests/imagecolormatch_error2.phpt @@ -15,9 +15,9 @@ $background_color = imagecolorallocate($imb, 0, 0, 100); try { imagecolormatch($ima, $imb); } catch (ValueError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } ?> --EXPECT-- -imagecolormatch(): Argument #1 ($image1) must be TrueColor +ValueError: imagecolormatch(): Argument #1 ($image1) must be TrueColor diff --git a/ext/gd/tests/imagecolormatch_error3.phpt b/ext/gd/tests/imagecolormatch_error3.phpt index 9b0d4c8830c7..02101585b979 100644 --- a/ext/gd/tests/imagecolormatch_error3.phpt +++ b/ext/gd/tests/imagecolormatch_error3.phpt @@ -15,9 +15,9 @@ $background_color = imagecolorallocate($imb, 0, 0, 100); try { imagecolormatch($ima, $imb); } catch (ValueError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } ?> --EXPECT-- -imagecolormatch(): Argument #2 ($image2) must be Palette +ValueError: imagecolormatch(): Argument #2 ($image2) must be Palette diff --git a/ext/gd/tests/imagecolormatch_error4.phpt b/ext/gd/tests/imagecolormatch_error4.phpt index e4aa04ca3d37..2c117dcd46ab 100644 --- a/ext/gd/tests/imagecolormatch_error4.phpt +++ b/ext/gd/tests/imagecolormatch_error4.phpt @@ -15,9 +15,9 @@ $background_color = imagecolorallocate($imb, 0, 0, 100); try { imagecolormatch($ima, $imb); } catch (ValueError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } ?> --EXPECT-- -imagecolormatch(): Argument #2 ($image2) must be the same size as argument #1 ($im1) +ValueError: imagecolormatch(): Argument #2 ($image2) must be the same size as argument #1 ($im1) diff --git a/ext/gd/tests/imagecrop_overflow.phpt b/ext/gd/tests/imagecrop_overflow.phpt index 3331a6267168..4edfb985ae95 100644 --- a/ext/gd/tests/imagecrop_overflow.phpt +++ b/ext/gd/tests/imagecrop_overflow.phpt @@ -11,7 +11,7 @@ $arr = ["x" => 2147483647, "y" => 2147483647, "width" => 10, "height" => 10]; try { imagecrop($img, $arr); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } $arr = ["x" => -2147483648, "y" => 0, "width" => -10, "height" => 10]; @@ -19,7 +19,7 @@ $arr = ["x" => -2147483648, "y" => 0, "width" => -10, "height" => 10]; try { imagecrop($img, $arr); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } $arr = ["x" => 1, "y" => 2147483647, "width" => 10, "height" => 10]; @@ -27,7 +27,7 @@ $arr = ["x" => 1, "y" => 2147483647, "width" => 10, "height" => 10]; try { imagecrop($img, $arr); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } $arr = ["x" => 1, "y" => -2147483648, "width" => 10, "height" => -10]; @@ -35,11 +35,11 @@ $arr = ["x" => 1, "y" => -2147483648, "width" => 10, "height" => -10]; try { imagecrop($img, $arr); } catch (\ValueError $e) { - echo $e->getMessage(); + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } ?> --EXPECT-- -imagecrop(): Argument #2 ($rectangle) overflow with "x" and "width" keys -imagecrop(): Argument #2 ($rectangle) underflow with "x" and "width" keys -imagecrop(): Argument #2 ($rectangle) overflow with "y" and "height" keys -imagecrop(): Argument #2 ($rectangle) underflow with "y" and "height" keys +ValueError: imagecrop(): Argument #2 ($rectangle) overflow with "x" and "width" keys +ValueError: imagecrop(): Argument #2 ($rectangle) underflow with "x" and "width" keys +ValueError: imagecrop(): Argument #2 ($rectangle) overflow with "y" and "height" keys +ValueError: imagecrop(): Argument #2 ($rectangle) underflow with "y" and "height" keys diff --git a/ext/gd/tests/imagefilter2.phpt b/ext/gd/tests/imagefilter2.phpt index 99b73ffc133d..5f0ec6615ae6 100644 --- a/ext/gd/tests/imagefilter2.phpt +++ b/ext/gd/tests/imagefilter2.phpt @@ -20,17 +20,17 @@ foreach ([-1, PHP_INT_MAX] as $val) { try { imagefilter($im, IMG_FILTER_SCATTER, $val, 0); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { imagefilter($im, IMG_FILTER_SCATTER, 0, $val); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } } ?> --EXPECTF-- -imagefilter(): Argument #3 must be between 0 and %d -imagefilter(): Argument #4 must be between 0 and %d -imagefilter(): Argument #3 must be between 0 and %d -imagefilter(): Argument #4 must be between 0 and %d +ValueError: imagefilter(): Argument #3 must be between 0 and %d +ValueError: imagefilter(): Argument #4 must be between 0 and %d +ValueError: imagefilter(): Argument #3 must be between 0 and %d +ValueError: imagefilter(): Argument #4 must be between 0 and %d diff --git a/ext/gd/tests/imagefilter_error1.phpt b/ext/gd/tests/imagefilter_error1.phpt index cc9904e320da..f2e6e1c3e696 100644 --- a/ext/gd/tests/imagefilter_error1.phpt +++ b/ext/gd/tests/imagefilter_error1.phpt @@ -12,14 +12,14 @@ $image = imagecreatetruecolor(180, 30); try { var_dump(imagefilter($image)); } catch (TypeError $e) { - echo $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump(imagefilter(20, 1)); } catch (TypeError $e) { - echo $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- -imagefilter() expects at least 2 arguments, 1 given -imagefilter(): Argument #1 ($image) must be of type GdImage, int given +ArgumentCountError: imagefilter() expects at least 2 arguments, 1 given +TypeError: imagefilter(): Argument #1 ($image) must be of type GdImage, int given diff --git a/ext/gd/tests/imagegd2_nullbyte_injection.phpt b/ext/gd/tests/imagegd2_nullbyte_injection.phpt index 5765543be1df..95995b78b1f2 100644 --- a/ext/gd/tests/imagegd2_nullbyte_injection.phpt +++ b/ext/gd/tests/imagegd2_nullbyte_injection.phpt @@ -8,8 +8,8 @@ $image = imagecreate(1,1);// 1px image try { imagegd($image, "./foo\0bar"); } catch (ValueError $e) { - echo $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- -imagegd(): Argument #2 ($file) must not contain any null bytes +ValueError: imagegd(): Argument #2 ($file) must not contain any null bytes diff --git a/ext/gd/tests/imagegd_nullbyte_injection.phpt b/ext/gd/tests/imagegd_nullbyte_injection.phpt index 657e11dd1788..fe4490acdde8 100644 --- a/ext/gd/tests/imagegd_nullbyte_injection.phpt +++ b/ext/gd/tests/imagegd_nullbyte_injection.phpt @@ -8,8 +8,8 @@ $image = imagecreate(1,1);// 1px image try { imagegd($image, "./foo\0bar"); } catch (ValueError $e) { - echo $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- -imagegd(): Argument #2 ($file) must not contain any null bytes +ValueError: imagegd(): Argument #2 ($file) must not contain any null bytes diff --git a/ext/gd/tests/imagegif_nullbyte_injection.phpt b/ext/gd/tests/imagegif_nullbyte_injection.phpt index 5cdb6f6879f8..a0b98badb2d4 100644 --- a/ext/gd/tests/imagegif_nullbyte_injection.phpt +++ b/ext/gd/tests/imagegif_nullbyte_injection.phpt @@ -8,8 +8,8 @@ $image = imagecreate(1,1);// 1px image try { imagegif($image, "./foo\0bar"); } catch (TypeError $e) { - echo $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- -imagegif(): Argument #2 ($file) must not contain null bytes +TypeError: imagegif(): Argument #2 ($file) must not contain null bytes diff --git a/ext/gd/tests/imagejpeg_nullbyte_injection.phpt b/ext/gd/tests/imagejpeg_nullbyte_injection.phpt index 6863626a0c93..1b260de67521 100644 --- a/ext/gd/tests/imagejpeg_nullbyte_injection.phpt +++ b/ext/gd/tests/imagejpeg_nullbyte_injection.phpt @@ -15,8 +15,8 @@ $image = imagecreate(1,1);// 1px image try { imagejpeg($image, "./foo\0bar"); } catch (TypeError $e) { - echo $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- -imagejpeg(): Argument #2 ($file) must not contain null bytes +TypeError: imagejpeg(): Argument #2 ($file) must not contain null bytes diff --git a/ext/gd/tests/imagepng_nullbyte_injection.phpt b/ext/gd/tests/imagepng_nullbyte_injection.phpt index f5ec342b9c6e..ca04a5be9e1a 100644 --- a/ext/gd/tests/imagepng_nullbyte_injection.phpt +++ b/ext/gd/tests/imagepng_nullbyte_injection.phpt @@ -15,8 +15,8 @@ $image = imagecreate(1,1);// 1px image try { imagepng($image, "./foo\0bar"); } catch (TypeError $e) { - echo $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- -imagepng(): Argument #2 ($file) must not contain null bytes +TypeError: imagepng(): Argument #2 ($file) must not contain null bytes diff --git a/ext/gd/tests/imageresolution_basic.phpt b/ext/gd/tests/imageresolution_basic.phpt index 74dc8c59dcda..d50173eb74d0 100644 --- a/ext/gd/tests/imageresolution_basic.phpt +++ b/ext/gd/tests/imageresolution_basic.phpt @@ -18,17 +18,17 @@ $res = imageresolution($exp); try { imageresolution($exp, PHP_INT_MAX); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { imageresolution($exp, 127, -PHP_INT_MAX); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } imageresolution($exp, 0, 0); var_dump(imageresolution($exp) == $res); ?> --EXPECTF-- -imageresolution(): Argument #2 ($resolution_x) must be between 0 and %d -imageresolution(): Argument #3 ($resolution_y) must be between 0 and %d +ValueError: imageresolution(): Argument #2 ($resolution_x) must be between 0 and %d +ValueError: imageresolution(): Argument #3 ($resolution_y) must be between 0 and %d bool(true) diff --git a/ext/gd/tests/imageresolution_jpeg.phpt b/ext/gd/tests/imageresolution_jpeg.phpt index 739b6949a871..a918c7402d2c 100644 --- a/ext/gd/tests/imageresolution_jpeg.phpt +++ b/ext/gd/tests/imageresolution_jpeg.phpt @@ -27,7 +27,7 @@ imageresolution($exp, 71, 299); try { imagejpeg($exp, $filename, 101); } catch (\ValueError $e) { - echo $e->getMessage(); + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } ?> --EXPECT-- @@ -43,7 +43,7 @@ array(2) { [1]=> int(299) } -imagejpeg(): Argument #3 ($quality) must be at between -1 and 100 +ValueError: imagejpeg(): Argument #3 ($quality) must be at between -1 and 100 --CLEAN-- getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- -imagewbmp(): Argument #2 ($file) must not contain null bytes +TypeError: imagewbmp(): Argument #2 ($file) must not contain null bytes diff --git a/ext/gd/tests/imagewebp_nullbyte_injection.phpt b/ext/gd/tests/imagewebp_nullbyte_injection.phpt index 3fcb687eeeab..27169d6f4639 100644 --- a/ext/gd/tests/imagewebp_nullbyte_injection.phpt +++ b/ext/gd/tests/imagewebp_nullbyte_injection.phpt @@ -15,8 +15,8 @@ $image = imagecreate(1,1);// 1px image try { imagewebp($image, "./foo\0bar"); } catch (TypeError $e) { - echo $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- -imagewebp(): Argument #2 ($file) must not contain null bytes +TypeError: imagewebp(): Argument #2 ($file) must not contain null bytes diff --git a/ext/gd/tests/imagexbm_nullbyte_injection.phpt b/ext/gd/tests/imagexbm_nullbyte_injection.phpt index 701f910014c2..59892a25af59 100644 --- a/ext/gd/tests/imagexbm_nullbyte_injection.phpt +++ b/ext/gd/tests/imagexbm_nullbyte_injection.phpt @@ -8,8 +8,8 @@ $image = imagecreate(1,1);// 1px image try { imagexbm($image, "./foo\0bar"); } catch (ValueError $e) { - echo $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- -imagexbm(): Argument #2 ($filename) must not contain any null bytes +ValueError: imagexbm(): Argument #2 ($filename) must not contain any null bytes diff --git a/ext/gd/tests/pngcomp.phpt b/ext/gd/tests/pngcomp.phpt index 81beacad8a54..c6b65dd08139 100644 --- a/ext/gd/tests/pngcomp.phpt +++ b/ext/gd/tests/pngcomp.phpt @@ -18,12 +18,12 @@ gd try { imagepng($im, $cwd . '/test_pngcomp.png', -2); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { imagepng($im, $cwd . '/test_pngcomp.png', 10); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } echo "PNG compression test: "; imagepng($im, $cwd . '/test_pngcomp.png', 9); @@ -37,6 +37,6 @@ gd @unlink($cwd . "/test_pngcomp.png"); ?> --EXPECT-- -imagepng(): Argument #3 ($quality) must be between -1 and 9 -imagepng(): Argument #3 ($quality) must be between -1 and 9 +ValueError: imagepng(): Argument #3 ($quality) must be between -1 and 9 +ValueError: imagepng(): Argument #3 ($quality) must be between -1 and 9 PNG compression test: ok diff --git a/ext/gd/tests/webp_basic.phpt b/ext/gd/tests/webp_basic.phpt index ef2fae865256..9f6272c52938 100644 --- a/ext/gd/tests/webp_basic.phpt +++ b/ext/gd/tests/webp_basic.phpt @@ -40,7 +40,7 @@ var_dump(mse($im1, $im_lossless) == 0); try { imagewebp($im1, $filename, -10); } catch (\ValueError $e) { - echo $e->getMessage(); + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } ?> @@ -51,4 +51,4 @@ try { --EXPECT-- Is lossy conversion close enough? bool(true) Does lossless conversion work? bool(true) -imagewebp(): Argument #3 ($quality) must be greater than or equal to -1 +ValueError: imagewebp(): Argument #3 ($quality) must be greater than or equal to -1 diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c index b45e7416c773..2f1fa1c21c55 100644 --- a/ext/mysqli/mysqli.c +++ b/ext/mysqli/mysqli.c @@ -674,6 +674,8 @@ PHP_METHOD(mysqli_stmt, __construct) RETURN_FALSE; } mysqli_resource->status = MYSQLI_STATUS_VALID; + } else { + zend_error(E_DEPRECATED, "Instantiation of mysqli_stmt without providing the $query parameter is deprecated"); } } diff --git a/ext/mysqli/mysqli.stub.php b/ext/mysqli/mysqli.stub.php index c995cf564a57..6ff946299ddf 100644 --- a/ext/mysqli/mysqli.stub.php +++ b/ext/mysqli/mysqli.stub.php @@ -996,6 +996,7 @@ public function stat(): string|false {} * @tentative-return-type * @alias mysqli_stmt_init */ + #[\Deprecated(since: '8.6', message: 'use mysqli::prepare() instead')] public function stmt_init(): mysqli_stmt|false {} /** @@ -1610,6 +1611,7 @@ function mysqli_stmt_get_result(mysqli_stmt $statement): mysqli_result|false {} function mysqli_stmt_get_warnings(mysqli_stmt $statement): mysqli_warning|false {} /** @refcount 1 */ +#[\Deprecated(since: '8.6', message: 'use mysqli_prepare() instead')] function mysqli_stmt_init(mysqli $mysql): mysqli_stmt|false {} /** @refcount 1 */ diff --git a/ext/mysqli/mysqli_arginfo.h b/ext/mysqli/mysqli_arginfo.h index 1cb07ae964ad..32588d45e268 100644 --- a/ext/mysqli/mysqli_arginfo.h +++ b/ext/mysqli/mysqli_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit mysqli.stub.php instead. - * Stub hash: d31c6ff508415337f4536e8e476168882e769158 */ + * Stub hash: f5327d48b275a5358b740232281478c83bb8a3db */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mysqli_affected_rows, 0, 1, MAY_BE_LONG|MAY_BE_STRING) ZEND_ARG_OBJ_INFO(0, mysql, mysqli, 0) @@ -913,7 +913,7 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(mysqli_stmt_free_result, arginfo_mysqli_stmt_free_result) ZEND_FE(mysqli_stmt_get_result, arginfo_mysqli_stmt_get_result) ZEND_FE(mysqli_stmt_get_warnings, arginfo_mysqli_stmt_get_warnings) - ZEND_FE(mysqli_stmt_init, arginfo_mysqli_stmt_init) + ZEND_RAW_FENTRY("mysqli_stmt_init", zif_mysqli_stmt_init, arginfo_mysqli_stmt_init, ZEND_ACC_DEPRECATED, NULL, NULL) ZEND_FE(mysqli_stmt_insert_id, arginfo_mysqli_stmt_insert_id) ZEND_FE(mysqli_stmt_more_results, arginfo_mysqli_stmt_more_results) ZEND_FE(mysqli_stmt_next_result, arginfo_mysqli_stmt_next_result) @@ -978,7 +978,7 @@ static const zend_function_entry class_mysqli_methods[] = { ZEND_RAW_FENTRY("set_opt", zif_mysqli_options, arginfo_class_mysqli_set_opt, ZEND_ACC_PUBLIC, NULL, NULL) ZEND_RAW_FENTRY("ssl_set", zif_mysqli_ssl_set, arginfo_class_mysqli_ssl_set, ZEND_ACC_PUBLIC, NULL, NULL) ZEND_RAW_FENTRY("stat", zif_mysqli_stat, arginfo_class_mysqli_stat, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("stmt_init", zif_mysqli_stmt_init, arginfo_class_mysqli_stmt_init, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("stmt_init", zif_mysqli_stmt_init, arginfo_class_mysqli_stmt_init, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED, NULL, NULL) ZEND_RAW_FENTRY("store_result", zif_mysqli_store_result, arginfo_class_mysqli_store_result, ZEND_ACC_PUBLIC, NULL, NULL) ZEND_RAW_FENTRY("thread_safe", zif_mysqli_thread_safe, arginfo_class_mysqli_thread_safe, ZEND_ACC_PUBLIC, NULL, NULL) ZEND_RAW_FENTRY("use_result", zif_mysqli_use_result, arginfo_class_mysqli_use_result, ZEND_ACC_PUBLIC, NULL, NULL) @@ -1190,6 +1190,13 @@ static void register_mysqli_symbols(int module_number) zend_add_parameter_attribute(zend_hash_str_find_ptr(CG(function_table), "mysqli_real_connect", sizeof("mysqli_real_connect") - 1), 3, ZSTR_KNOWN(ZEND_STR_SENSITIVEPARAMETER), 0); + zend_attribute *attribute_Deprecated_func_mysqli_stmt_init_0 = zend_add_function_attribute(zend_hash_str_find_ptr(CG(function_table), "mysqli_stmt_init", sizeof("mysqli_stmt_init") - 1), ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); + ZVAL_STR(&attribute_Deprecated_func_mysqli_stmt_init_0->args[0].value, ZSTR_KNOWN(ZEND_STR_8_DOT_6)); + attribute_Deprecated_func_mysqli_stmt_init_0->args[0].name = ZSTR_KNOWN(ZEND_STR_SINCE); + zend_string *attribute_Deprecated_func_mysqli_stmt_init_0_arg1_str = zend_string_init("use mysqli_prepare() instead", strlen("use mysqli_prepare() instead"), 1); + ZVAL_STR(&attribute_Deprecated_func_mysqli_stmt_init_0->args[1].value, attribute_Deprecated_func_mysqli_stmt_init_0_arg1_str); + attribute_Deprecated_func_mysqli_stmt_init_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); + zend_attribute *attribute_Deprecated_func_mysqli_refresh_0 = zend_add_function_attribute(zend_hash_str_find_ptr(CG(function_table), "mysqli_refresh", sizeof("mysqli_refresh") - 1), ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); ZVAL_STR(&attribute_Deprecated_func_mysqli_refresh_0->args[0].value, ZSTR_KNOWN(ZEND_STR_8_DOT_4)); attribute_Deprecated_func_mysqli_refresh_0->args[0].name = ZSTR_KNOWN(ZEND_STR_SINCE); @@ -1503,6 +1510,13 @@ static zend_class_entry *register_class_mysqli(void) zend_add_parameter_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "real_connect", sizeof("real_connect") - 1), 2, ZSTR_KNOWN(ZEND_STR_SENSITIVEPARAMETER), 0); + zend_attribute *attribute_Deprecated_func_stmt_init_0 = zend_add_function_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "stmt_init", sizeof("stmt_init") - 1), ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); + ZVAL_STR(&attribute_Deprecated_func_stmt_init_0->args[0].value, ZSTR_KNOWN(ZEND_STR_8_DOT_6)); + attribute_Deprecated_func_stmt_init_0->args[0].name = ZSTR_KNOWN(ZEND_STR_SINCE); + zend_string *attribute_Deprecated_func_stmt_init_0_arg1_str = zend_string_init("use mysqli::prepare() instead", strlen("use mysqli::prepare() instead"), 1); + ZVAL_STR(&attribute_Deprecated_func_stmt_init_0->args[1].value, attribute_Deprecated_func_stmt_init_0_arg1_str); + attribute_Deprecated_func_stmt_init_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); + zend_attribute *attribute_Deprecated_func_refresh_0 = zend_add_function_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "refresh", sizeof("refresh") - 1), ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); ZVAL_STR(&attribute_Deprecated_func_refresh_0->args[0].value, ZSTR_KNOWN(ZEND_STR_8_DOT_4)); attribute_Deprecated_func_refresh_0->args[0].name = ZSTR_KNOWN(ZEND_STR_SINCE); diff --git a/ext/mysqli/tests/bug38710.phpt b/ext/mysqli/tests/bug38710.phpt index 156f4b77a569..283ea78ae23f 100644 --- a/ext/mysqli/tests/bug38710.phpt +++ b/ext/mysqli/tests/bug38710.phpt @@ -11,8 +11,7 @@ require_once 'skipifconnectfailure.inc'; require_once 'connect.inc'; $db = new my_mysqli($host, $user, $passwd, $db, $port, $socket); -$qry=$db->stmt_init(); -$qry->prepare("SELECT REPEAT('a',100000)"); +$qry=$db->prepare("SELECT REPEAT('a',100000)"); $qry->execute(); $qry->bind_result($text); $qry->fetch(); diff --git a/ext/mysqli/tests/bug42378.phpt b/ext/mysqli/tests/bug42378.phpt index 67256859b484..3fb6c78d4b87 100644 --- a/ext/mysqli/tests/bug42378.phpt +++ b/ext/mysqli/tests/bug42378.phpt @@ -50,12 +50,6 @@ memory_limit=83886080 function test_format($link, $format, $from, $order_by, $expected, $offset) { - if (!$stmt = mysqli_stmt_init($link)) { - printf("[%03d] Cannot create PS, [%d] %s\n", - $offset, - mysqli_errno($link), mysqli_error($link)); - return false; - } print "$format\n"; if ($order_by) @@ -63,10 +57,10 @@ memory_limit=83886080 else $sql = sprintf('SELECT %s AS _format FROM %s', $format, $from); - if (!mysqli_stmt_prepare($stmt, $sql)) { + if (!$stmt = mysqli_prepare($link, $sql)) { printf("[%03d] Cannot prepare PS, [%d] %s\n", $offset + 1, - mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + mysqli_errno($link), mysqli_error($link)); return false; } diff --git a/ext/mysqli/tests/bug55653.phpt b/ext/mysqli/tests/bug55653.phpt index dd141e8476a0..b3f95e831e75 100644 --- a/ext/mysqli/tests/bug55653.phpt +++ b/ext/mysqli/tests/bug55653.phpt @@ -16,11 +16,10 @@ require_once 'skipifconnectfailure.inc'; $in_and_out = "a"; - if (!($stmt = $link->stmt_init())) + if (!($stmt = $link->prepare("SELECT ?"))) printf("[002] [%d] %s\n", $link->errno, $link->error); - if (!($stmt->prepare("SELECT ?")) || - !($stmt->bind_param("s", $in_and_out)) || + if (!($stmt->bind_param("s", $in_and_out)) || !($stmt->execute()) || !($stmt->bind_result($in_and_out))) printf("[003] [%d] %s\n", $stmt->errno, $stmt->error); diff --git a/ext/mysqli/tests/bug66043.phpt b/ext/mysqli/tests/bug66043.phpt index 83d234997c2a..da4ab9646665 100644 --- a/ext/mysqli/tests/bug66043.phpt +++ b/ext/mysqli/tests/bug66043.phpt @@ -1,5 +1,5 @@ --TEST-- -Bug #66043 (Segfault calling bind_param() on mysqli) +Bug #66043 (Segfault calling bind_param() on mysqli) - Calling mysql_stmt::bind_result() without storing it's result value in a variable is causing a segfault. --EXTENSIONS-- mysqli --SKIPIF-- @@ -9,38 +9,13 @@ require_once 'skipifconnectfailure.inc'; --FILE-- query("DROP TABLE IF EXISTS test")) { - printf("[002] [%d] %s\n", mysqli_errno($db), mysqli_error($db)); - die(); -} - -if (!$db->query("CREATE TABLE test(str TEXT)")) { - printf("[003] [%d] %s\n", mysqli_errno($db), mysqli_error($db)); - die(); -} - -if (!$db->query("INSERT INTO test(str) VALUES ('Test')")) { - printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - die(); -} - -$stmt = $db->stmt_init(); -if (!$stmt->prepare("SELECT str FROM test")) { - printf("[004] [%d] %s\n", mysqli_errno($db), mysqli_error($db)); - die(); -} +mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); +$db = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket); +$stmt = $db->prepare("SELECT 'Test'"); $stmt->execute(); $stmt->bind_result($testArg); echo "Okey"; ?> ---CLEAN-- - --EXPECT-- Okey diff --git a/ext/mysqli/tests/mysqli_class_mysqli_stmt_interface.phpt b/ext/mysqli/tests/mysqli_class_mysqli_stmt_interface.phpt index cc7e36727639..ca4e9a57c2f9 100644 --- a/ext/mysqli/tests/mysqli_class_mysqli_stmt_interface.phpt +++ b/ext/mysqli/tests/mysqli_class_mysqli_stmt_interface.phpt @@ -132,6 +132,7 @@ printf("stmt->unknown = '%s'\n", @$stmt->unknown); print "done!"; ?> --EXPECTF-- +Deprecated: Instantiation of mysqli_stmt without providing the $query parameter is deprecated in %s on line %d Parent class: bool(false) diff --git a/ext/mysqli/tests/mysqli_explain_metadata.phpt b/ext/mysqli/tests/mysqli_explain_metadata.phpt index 36067365ff67..5f57337f3317 100644 --- a/ext/mysqli/tests/mysqli_explain_metadata.phpt +++ b/ext/mysqli/tests/mysqli_explain_metadata.phpt @@ -59,9 +59,8 @@ require_once 'skipifconnectfailure.inc'; mysqli_free_result($res); - $stmt = mysqli_stmt_init($link); - /* Depending on your version, the MySQL server migit not support this */ - if ($stmt->prepare('EXPLAIN SELECT t1.*, t2.* FROM test AS t1, test AS t2') && $stmt->execute()) { + /* Depending on your version, the MySQL server might not support this */ + if (($stmt = $link->prepare('EXPLAIN SELECT t1.*, t2.* FROM test AS t1, test AS t2')) && $stmt->execute()) { if (!mysqli_stmt_store_result($stmt)) printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); diff --git a/ext/mysqli/tests/mysqli_get_client_stats.phpt b/ext/mysqli/tests/mysqli_get_client_stats.phpt index 17900c5ad609..0dd5fe3113e1 100644 --- a/ext/mysqli/tests/mysqli_get_client_stats.phpt +++ b/ext/mysqli/tests/mysqli_get_client_stats.phpt @@ -310,13 +310,12 @@ mysqli.allow_local_infile=1 mysqli_get_client_stats_assert_eq('flushed_normal_sets', $info, $expected, $test_counter); print "Testing buffered Prepared Statements...\n"; - if (!$stmt = mysqli_stmt_init($link)) - printf("[%03d] stmt_init() failed, [%d] %s\n", + if (!$stmt = mysqli_prepare($link, 'SELECT id, label FROM test')) + printf("[%03d] mysqli_prepare() failed, [%d] %s\n", ++$test_counter, mysqli_errno($link), mysqli_error($link)); - if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test') || - !mysqli_stmt_execute($stmt)) - printf("[%03d] prepare/execute failed, [%d] %s\n", + if (!mysqli_stmt_execute($stmt)) + printf("[%03d] mysqli_stmt_execute() failed, [%d] %s\n", ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); /* by default PS is unbuffered - no change */ diff --git a/ext/mysqli/tests/mysqli_get_client_stats_ps.phpt b/ext/mysqli/tests/mysqli_get_client_stats_ps.phpt index c0f6ddb3c354..d79db6345d31 100644 --- a/ext/mysqli/tests/mysqli_get_client_stats_ps.phpt +++ b/ext/mysqli/tests/mysqli_get_client_stats_ps.phpt @@ -19,12 +19,11 @@ mysqlnd.collect_memory_statistics=1 printf("BEGINNING: rows_fetched_from_client_ps_buffered = %d\n", $stats['rows_fetched_from_client_ps_buffered']); printf("BEGINNING: rows_fetched_from_client_ps_cursor = %d\n", $stats['rows_fetched_from_client_ps_cursor']); - if (!$stmt = mysqli_stmt_init($link)) + if (!$stmt = mysqli_prepare($link, 'SELECT id FROM test')) printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $id = null; - if (!mysqli_stmt_prepare($stmt, 'SELECT id FROM test') || - !mysqli_stmt_execute($stmt) || + if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_store_result($stmt) || !mysqli_stmt_bind_result($stmt, $id)) printf("[002] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); diff --git a/ext/mysqli/tests/mysqli_report.phpt b/ext/mysqli/tests/mysqli_report.phpt index da400ae4eee4..c2af15228266 100644 --- a/ext/mysqli/tests/mysqli_report.phpt +++ b/ext/mysqli/tests/mysqli_report.phpt @@ -33,6 +33,7 @@ require_once 'skipifconnectfailure.inc'; */ mysqli_report(MYSQLI_REPORT_ERROR); + $stmt = mysqli_prepare($link, "DO 1"); mysqli_multi_query($link, "BAR; FOO;"); mysqli_query($link, "FOO"); try { @@ -51,7 +52,6 @@ require_once 'skipifconnectfailure.inc'; mysqli_autocommit($link, true); mysqli_commit($link); mysqli_rollback($link); - $stmt = mysqli_stmt_init($link); mysqli_stmt_prepare($stmt, "SELECT id FROM test WHERE id > ?"); while(mysqli_more_results($link)) { mysqli_next_result($link); @@ -63,6 +63,7 @@ require_once 'skipifconnectfailure.inc'; // not have been set. If that would be the case, the test would be broken. mysqli_report(MYSQLI_REPORT_OFF); + $stmt = mysqli_prepare($link, "DO 1"); mysqli_multi_query($link, "BAR; FOO;"); mysqli_query($link, "FOO"); try { @@ -78,7 +79,6 @@ require_once 'skipifconnectfailure.inc'; mysqli_autocommit($link, true); mysqli_commit($link); mysqli_rollback($link); - $stmt = mysqli_stmt_init($link); mysqli_stmt_prepare($stmt, "SELECT id FROM test WHERE id > ?"); while(mysqli_more_results($link)) { mysqli_next_result($link); @@ -92,11 +92,10 @@ require_once 'skipifconnectfailure.inc'; mysqli_report(MYSQLI_REPORT_ERROR); - $stmt = mysqli_stmt_init($link); + $stmt = mysqli_prepare($link, "DO 1"); mysqli_stmt_prepare($stmt, "FOO"); - $stmt = mysqli_stmt_init($link); - mysqli_stmt_prepare($stmt, "SELECT id FROM test WHERE id > ?"); + $stmt = mysqli_prepare($link, "SELECT id FROM test WHERE id > ?"); $id = 1; mysqli_kill($link, mysqli_thread_id($link)); mysqli_stmt_bind_param($stmt, "i", $id); @@ -106,11 +105,10 @@ require_once 'skipifconnectfailure.inc'; /* mysqli_stmt_execute() = mysql_stmt_execute cannot be tested from PHP */ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[008] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); - $stmt = mysqli_stmt_init($link); - mysqli_stmt_prepare($stmt, "SELECT id FROM test WHERE id > ?"); + $stmt = mysqli_prepare($link, "SELECT id FROM test WHERE id > ?"); $id = 1; mysqli_stmt_bind_param($stmt, "i", $id); - // mysqli_kill($link, mysqli_thread_id($link)); + mysqli_kill($link, mysqli_thread_id($link)); mysqli_stmt_execute($stmt); mysqli_stmt_close($stmt); mysqli_close($link); @@ -126,11 +124,10 @@ require_once 'skipifconnectfailure.inc'; if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[010] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); - $stmt = mysqli_stmt_init($link); + $stmt = mysqli_prepare($link, "DO 1"); mysqli_stmt_prepare($stmt, "FOO"); - $stmt = mysqli_stmt_init($link); - mysqli_stmt_prepare($stmt, "SELECT id FROM test WHERE id > ?"); + $stmt = mysqli_prepare($link, "SELECT id FROM test WHERE id > ?"); $id = 1; mysqli_kill($link, mysqli_thread_id($link)); mysqli_stmt_bind_param($stmt, "i", $id); @@ -139,8 +136,7 @@ require_once 'skipifconnectfailure.inc'; if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[011] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); - $stmt = mysqli_stmt_init($link); - mysqli_stmt_prepare($stmt, "SELECT id FROM test WHERE id > ?"); + $stmt = mysqli_prepare($link, "SELECT id FROM test WHERE id > ?"); $id = 1; mysqli_stmt_bind_param($stmt, "i", $id); mysqli_kill($link, mysqli_thread_id($link)); @@ -257,7 +253,7 @@ require_once 'skipifconnectfailure.inc'; if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[024] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); - if (!$stmt = mysqli_stmt_init($link)) + if (!$stmt = mysqli_prepare($link, 'SELECT id * 3 FROM test')) printf("[025] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test')) @@ -284,11 +280,6 @@ require_once 'skipifconnectfailure.inc'; mysqli_free_result($res); - if (!$stmt = mysqli_prepare($link, 'SELECT id * 3 FROM test')) - printf("[032] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - else - mysqli_stmt_close($stmt); - if (!mysqli_query($link, "INSERT INTO test(id, label) VALUES (100, 'z')", MYSQLI_USE_RESULT) || !mysqli_query($link, 'DELETE FROM test WHERE id > 50', MYSQLI_USE_RESULT)) printf("[033] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); @@ -333,6 +324,10 @@ Deprecated: Function mysqli_kill() is deprecated since 8.4, use KILL CONNECTION/ Deprecated: Function mysqli_kill() is deprecated since 8.4, use KILL CONNECTION/QUERY SQL statement instead in %s +Warning: mysqli_stmt_execute(): (HY000/2006): MySQL server has gone away in %s on line %d + +Deprecated: Function mysqli_kill() is deprecated since 8.4, use KILL CONNECTION/QUERY SQL statement instead in %s + Deprecated: Function mysqli_kill() is deprecated since 8.4, use KILL CONNECTION/QUERY SQL statement instead in %s [013] Access denied for user '%s'@'%s'%r( \(using password: \w+\)){0,1}%r [016] Access denied for user '%s'@'%s'%r( \(using password: \w+\)){0,1}%r diff --git a/ext/mysqli/tests/mysqli_stmt_affected_rows.phpt b/ext/mysqli/tests/mysqli_stmt_affected_rows.phpt index 9c8035734f6e..17b5cc50cbae 100644 --- a/ext/mysqli/tests/mysqli_stmt_affected_rows.phpt +++ b/ext/mysqli/tests/mysqli_stmt_affected_rows.phpt @@ -14,10 +14,12 @@ require_once 'skipifconnectfailure.inc'; printf("Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); } - $stmt = mysqli_stmt_init($link); - if (!mysqli_stmt_prepare($stmt, 'DROP TABLE IF EXISTS test') || - !mysqli_stmt_execute($stmt)) { + if (!$stmt = mysqli_prepare($link, 'DROP TABLE IF EXISTS test')) { + printf("[000] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + + if (!mysqli_stmt_execute($stmt)) { printf("[003] Failed to drop old test table: [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); } @@ -30,59 +32,71 @@ require_once 'skipifconnectfailure.inc'; printf("[005] Expecting int/0, got %s/'%s'\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); - $stmt = mysqli_stmt_init($link); - if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (1, 'a')") || - !mysqli_stmt_execute($stmt)) + if (!$stmt = mysqli_prepare($link, "INSERT INTO test(id, label) VALUES (1, 'a')")) { + printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + + if (!mysqli_stmt_execute($stmt)) printf("[006] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); mysqli_stmt_close($stmt); - $stmt = mysqli_stmt_init($link); - if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (100, 'z')") || - !mysqli_stmt_execute($stmt)) + if (!$stmt = mysqli_prepare($link, "INSERT INTO test(id, label) VALUES (100, 'z')")) { + printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + + if (!mysqli_stmt_execute($stmt)) printf("[007] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (1 !== ($tmp = mysqli_stmt_affected_rows($stmt))) printf("[008] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); - $stmt = mysqli_stmt_init($link); - if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (100, 'z')") || - !mysqli_stmt_execute($stmt)) + if (!$stmt = mysqli_prepare($link, "INSERT INTO test(id, label) VALUES (100, 'z')")) { + printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + + if (!mysqli_stmt_execute($stmt)) // NOTE: the error message varies with the MySQL Server version, dump only the error code! printf("[009] [%d] (error message varies with the MySQL Server version, check the error code)\n", mysqli_stmt_errno($stmt)); /* an error occurred: affected rows should return -1 */ if (-1 !== ($tmp = mysqli_stmt_affected_rows($stmt))) - printf("[010] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); + printf("[010] Expecting int/-1, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); - $stmt = mysqli_stmt_init($link); - if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (1, 'a') ON DUPLICATE KEY UPDATE id = 4") || - !mysqli_stmt_execute($stmt)) + if (!$stmt = mysqli_prepare($link, "INSERT INTO test(id, label) VALUES (1, 'a') ON DUPLICATE KEY UPDATE id = 4")) { + printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + + if (!mysqli_stmt_execute($stmt)) printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (2 !== ($tmp = mysqli_stmt_affected_rows($stmt))) printf("[012] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); - $stmt = mysqli_stmt_init($link); - if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (2, 'b'), (3, 'c')") || - !mysqli_stmt_execute($stmt)) + if (!$stmt = mysqli_prepare($link, "INSERT INTO test(id, label) VALUES (2, 'b'), (3, 'c')")) { + printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + + if (!mysqli_stmt_execute($stmt)) printf("[013] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (2 !== ($tmp = mysqli_stmt_affected_rows($stmt))) printf("[014] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); - $stmt = mysqli_stmt_init($link); - if (!mysqli_stmt_prepare($stmt, "INSERT IGNORE INTO test(id, label) VALUES (1, 'a')") || - !mysqli_stmt_execute($stmt)) + if (!$stmt = mysqli_prepare($link, "INSERT IGNORE INTO test(id, label) VALUES (1, 'a')")) { + printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + + if (!mysqli_stmt_execute($stmt)) printf("[015] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (1 !== ($tmp = mysqli_stmt_affected_rows($stmt))) @@ -95,40 +109,48 @@ require_once 'skipifconnectfailure.inc'; mysqli_free_result($res); mysqli_stmt_close($stmt); - $stmt = mysqli_stmt_init($link); - if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) SELECT id + 10, label FROM test") || - !mysqli_stmt_execute($stmt)) + if (!$stmt = mysqli_prepare($link, "INSERT INTO test(id, label) SELECT id + 10, label FROM test")) { + printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + + if (!mysqli_stmt_execute($stmt)) printf("[018] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if ($num !== ($tmp = mysqli_stmt_affected_rows($stmt))) printf("[019] Expecting int/%d, got %s/%s\n", $num, gettype($tmp), $tmp); mysqli_stmt_close($stmt); - $stmt = mysqli_stmt_init($link); - if (!mysqli_stmt_prepare($stmt, "REPLACE INTO test(id, label) values (4, 'd')") || - !mysqli_stmt_execute($stmt)) + if (!$stmt = mysqli_prepare($link, "REPLACE INTO test(id, label) values (4, 'd')")) { + printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + + if (!mysqli_stmt_execute($stmt)) printf("[020] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (2 !== ($tmp = mysqli_stmt_affected_rows($stmt))) printf("[021] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); - $stmt = mysqli_stmt_init($link); - if (!mysqli_stmt_prepare($stmt, "REPLACE INTO test(id, label) values (5, 'e')") || - !mysqli_stmt_execute($stmt)) + if (!$stmt = mysqli_prepare($link, "REPLACE INTO test(id, label) values (5, 'e')")) { + printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + + if (!mysqli_stmt_execute($stmt)) printf("[022] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (1 !== ($tmp = mysqli_stmt_affected_rows($stmt))) printf("[023] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); - $stmt = mysqli_stmt_init($link); - if (!mysqli_stmt_prepare($stmt, "UPDATE test SET label = 'a' WHERE id = 2") || - !mysqli_stmt_execute($stmt)) + if (!$stmt = mysqli_prepare($link, "UPDATE test SET label = 'a' WHERE id = 2")) { + printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + + if (!mysqli_stmt_execute($stmt)) printf("[024] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (1 !== ($tmp = mysqli_stmt_affected_rows($stmt))) @@ -142,10 +164,12 @@ require_once 'skipifconnectfailure.inc'; printf("[027] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); - $stmt = mysqli_stmt_init($link); - if (!mysqli_stmt_prepare($stmt, "UPDATE test SET label = 'a' WHERE id = 100") || - !mysqli_stmt_execute($stmt)) + if (!$stmt = mysqli_prepare($link, "UPDATE test SET label = 'a' WHERE id = 100")) { + printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + + if (!mysqli_stmt_execute($stmt)) printf("[028] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (1 !== ($tmp = mysqli_stmt_affected_rows($stmt))) @@ -174,10 +198,12 @@ require_once 'skipifconnectfailure.inc'; mysqli_stmt_free_result($stmt); mysqli_stmt_close($stmt); - $stmt = mysqli_stmt_init($link); - if (!mysqli_stmt_prepare($stmt, 'SELECT label FROM test WHERE 1 = 2') || - !mysqli_stmt_execute($stmt)) + if (!$stmt = mysqli_prepare($link, 'SELECT label FROM test WHERE 1 = 2')) { + printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + + if (!mysqli_stmt_execute($stmt)) printf("[036] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); /* use it like num_rows */ @@ -212,10 +238,12 @@ require_once 'skipifconnectfailure.inc'; printf("[045] Expecting int/-1, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); - $stmt = mysqli_stmt_init($link); - if (!mysqli_stmt_prepare($stmt, "DROP TABLE IF EXISTS test") || - !mysqli_stmt_execute($stmt)) + if (!$stmt = mysqli_prepare($link, "DROP TABLE IF EXISTS test")) { + printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + + if (!mysqli_stmt_execute($stmt)) printf("[046] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); mysqli_stmt_close($stmt); diff --git a/ext/mysqli/tests/mysqli_stmt_attr_get.phpt b/ext/mysqli/tests/mysqli_stmt_attr_get.phpt index 0c6f43e2ee8b..e509fc022e0b 100644 --- a/ext/mysqli/tests/mysqli_stmt_attr_get.phpt +++ b/ext/mysqli/tests/mysqli_stmt_attr_get.phpt @@ -15,8 +15,7 @@ require_once 'skipifconnectfailure.inc'; MYSQLI_STMT_ATTR_CURSOR_TYPE, ); - $stmt = mysqli_stmt_init($link); - mysqli_stmt_prepare($stmt, 'SELECT * FROM test'); + $stmt = mysqli_prepare($link, 'SELECT * FROM test'); try { mysqli_stmt_attr_get($stmt, -100); diff --git a/ext/mysqli/tests/mysqli_stmt_attr_set.phpt b/ext/mysqli/tests/mysqli_stmt_attr_set.phpt index f9cd1bac611a..37214f8ab70f 100644 --- a/ext/mysqli/tests/mysqli_stmt_attr_set.phpt +++ b/ext/mysqli/tests/mysqli_stmt_attr_set.phpt @@ -36,8 +36,7 @@ require_once 'skipifconnectfailure.inc'; // MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH // // expecting max_length not to be set and be 0 in all cases - $stmt = mysqli_stmt_init($link); - $stmt->prepare("SELECT label FROM test"); + $stmt = $link->prepare("SELECT label FROM test"); $stmt->execute(); $stmt->store_result(); $res = $stmt->result_metadata(); @@ -50,8 +49,7 @@ require_once 'skipifconnectfailure.inc'; $stmt->close(); // MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH is no longer supported, expect no change in behavior. - $stmt = mysqli_stmt_init($link); - $stmt->prepare("SELECT label FROM test"); + $stmt = $link->prepare("SELECT label FROM test"); var_dump($stmt->attr_set(MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH, 1)); $res = $stmt->attr_get(MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH); if ($res !== 1) @@ -68,8 +66,7 @@ require_once 'skipifconnectfailure.inc'; $stmt->close(); // expecting max_length not to be set - $stmt = mysqli_stmt_init($link); - $stmt->prepare("SELECT label FROM test"); + $stmt = $link->prepare("SELECT label FROM test"); $stmt->attr_set(MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH, 0); $res = $stmt->attr_get(MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH); if ($res !== 0) @@ -90,8 +87,7 @@ require_once 'skipifconnectfailure.inc'; // - $stmt = mysqli_stmt_init($link); - $stmt->prepare("SELECT id, label FROM test"); + $stmt = $link->prepare("SELECT id, label FROM test"); // Invalid cursor type try { @@ -108,8 +104,7 @@ require_once 'skipifconnectfailure.inc'; $stmt->close(); - $stmt = mysqli_stmt_init($link); - $stmt->prepare("SELECT id, label FROM test"); + $stmt = $link->prepare("SELECT id, label FROM test"); $stmt->execute(); $id = $label = NULL; $stmt->bind_result($id, $label); @@ -120,8 +115,7 @@ require_once 'skipifconnectfailure.inc'; if (empty($results)) printf("[015] Results should not be empty, subsequent tests will probably fail!\n"); - $stmt = mysqli_stmt_init($link); - $stmt->prepare("SELECT id, label FROM test"); + $stmt = $link->prepare("SELECT id, label FROM test"); if (true !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, MYSQLI_CURSOR_TYPE_NO_CURSOR))) printf("[016] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); $stmt->execute(); @@ -137,8 +131,7 @@ require_once 'skipifconnectfailure.inc'; var_dump($results2); } - $stmt = mysqli_stmt_init($link); - $stmt->prepare("SELECT id, label FROM test"); + $stmt = $link->prepare("SELECT id, label FROM test"); if (true !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, MYSQLI_CURSOR_TYPE_READ_ONLY))) printf("[018] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); $stmt->execute(); @@ -161,7 +154,8 @@ require_once 'skipifconnectfailure.inc'; ---EXPECT-- +--EXPECTF-- +Deprecated: Function mysqli_stmt_init() is deprecated since 8.6, use mysqli_prepare() instead in %s on line %d Error: mysqli_stmt object is not fully initialized mysqli_stmt_attr_set(): Argument #2 ($attribute) must be either MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH or MYSQLI_STMT_ATTR_CURSOR_TYPE mysqli_stmt::attr_set(): Argument #2 ($value) must be 0 or 1 for attribute MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH diff --git a/ext/mysqli/tests/mysqli_stmt_bind_param.phpt b/ext/mysqli/tests/mysqli_stmt_bind_param.phpt index 573a88689d66..bbe74bdb389a 100644 --- a/ext/mysqli/tests/mysqli_stmt_bind_param.phpt +++ b/ext/mysqli/tests/mysqli_stmt_bind_param.phpt @@ -19,9 +19,8 @@ require_once 'skipifconnectfailure.inc'; */ require 'table.inc'; - $stmt = mysqli_stmt_init($link); - if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) - printf("[003] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!$stmt = mysqli_prepare($link, "INSERT INTO test(id, label) VALUES (?, ?)")) + printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $id = null; $label = null; @@ -136,16 +135,11 @@ require_once 'skipifconnectfailure.inc'; return false; } - if (!$stmt = mysqli_stmt_init($link)) { + if (!$stmt = mysqli_prepare($link, "INSERT INTO test(id, label) VALUE (?, ?)")) { printf("[%03d] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link)); return false; } - if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUE (?, ?)")) { - printf("[%03d] [%d] %s\n", $offset + 2, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - return false; - } - $id = 1; if (!mysqli_stmt_bind_param($stmt, "i" . $bind_type, $id, $bind_value)) { printf("[%03d] [%d] %s\n", $offset + 3, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); @@ -333,9 +327,8 @@ require_once 'skipifconnectfailure.inc'; if (mysqli_get_server_version($link) >= 50600) func_mysqli_stmt_bind_datatype($link, $engine, "s", "TIME", "13:27:34.123456", 890, "13:27:34"); - $stmt = mysqli_stmt_init($link); - if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) - printf("[2000] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!$stmt = mysqli_prepare($link, "INSERT INTO test(id, label) VALUES (?, ?)")) + printf("[2000] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $id = null; $label = null; @@ -350,12 +343,9 @@ require_once 'skipifconnectfailure.inc'; mysqli_stmt_close($stmt); include 'table.inc'; - if (!$stmt = mysqli_stmt_init($link)) + if (!$stmt = mysqli_prepare($link, "INSERT INTO test(id, label) VALUES (?, ?)")) printf("[2003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) - printf("[2004] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - $id = $label = null; if (true !== ($tmp = $stmt->bind_param('is', $id, $label))) printf("[2005] Expecting boolean/true got %s/%s, [%d] %s\n", diff --git a/ext/mysqli/tests/mysqli_stmt_bind_param_call_user_func.phpt b/ext/mysqli/tests/mysqli_stmt_bind_param_call_user_func.phpt index 844d2974af00..42018e41ec75 100644 --- a/ext/mysqli/tests/mysqli_stmt_bind_param_call_user_func.phpt +++ b/ext/mysqli/tests/mysqli_stmt_bind_param_call_user_func.phpt @@ -11,12 +11,9 @@ require_once 'skipifconnectfailure.inc'; require 'connect.inc'; require 'table.inc'; - if (!$stmt = mysqli_stmt_init($link)) + if (!$stmt = mysqli_prepare($link, 'SELECT id, label FROM test WHERE id = ?')) printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test WHERE id = ?')) - printf("[002] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - $id = 1; if (!mysqli_stmt_bind_param($stmt, 'i', $id) || !mysqli_stmt_execute($stmt)) @@ -32,12 +29,9 @@ require_once 'skipifconnectfailure.inc'; var_dump($label); mysqli_stmt_close($stmt); - if (!$stmt = mysqli_stmt_init($link)) + if (!$stmt = mysqli_prepare($link, 'SELECT id, label FROM test WHERE id = ?')) printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test WHERE id = ?')) - printf("[006] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - $types = 'i'; $id = 1; $params = array( @@ -61,12 +55,9 @@ require_once 'skipifconnectfailure.inc'; var_dump($label); mysqli_stmt_close($stmt); - if (!$stmt = mysqli_stmt_init($link)) + if (!$stmt = mysqli_prepare($link, 'SELECT id, label FROM test WHERE id = ?')) printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test WHERE id = ?')) - printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - $types = 'i'; $id = 1; $params = array( @@ -89,12 +80,9 @@ require_once 'skipifconnectfailure.inc'; var_dump($label); mysqli_stmt_close($stmt); - if (!$stmt = mysqli_stmt_init($link)) + if (!$stmt = mysqli_prepare($link, 'SELECT id, label FROM test WHERE id = ?')) printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test WHERE id = ?')) - printf("[016] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - $types = 'i'; $id = 1; $params = array( @@ -117,12 +105,9 @@ require_once 'skipifconnectfailure.inc'; var_dump($label); mysqli_stmt_close($stmt); - if (!$stmt = mysqli_stmt_init($link)) + if (!$stmt = mysqli_prepare($link, 'SELECT id, label FROM test WHERE id = ?')) printf("[020] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test WHERE id = ?')) - printf("[021] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - $id = 1; $params = array( 0 => 'i', @@ -144,12 +129,9 @@ require_once 'skipifconnectfailure.inc'; var_dump($label); mysqli_stmt_close($stmt); - if (!$stmt = mysqli_stmt_init($link)) + if (!$stmt = mysqli_prepare($link, 'SELECT id, label FROM test WHERE id = ?')) printf("[025] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test WHERE id = ?')) - printf("[026] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - $types = 'i'; $id = 1; $params = array( @@ -173,12 +155,9 @@ require_once 'skipifconnectfailure.inc'; var_dump($label); mysqli_stmt_close($stmt); - if (!$stmt = mysqli_stmt_init($link)) + if (!$stmt = mysqli_prepare($link, 'SELECT id, label FROM test WHERE id = ?')) printf("[025] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test WHERE id = ?')) - printf("[026] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - $types = 'i'; $id = 1; $params = array( @@ -202,12 +181,9 @@ require_once 'skipifconnectfailure.inc'; var_dump($label); mysqli_stmt_close($stmt); - if (!$stmt = mysqli_stmt_init($link)) + if (!$stmt = mysqli_prepare($link, 'SELECT id, label FROM test WHERE id = ?')) printf("[030] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test WHERE id = ?')) - printf("[031] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - $types = 'i'; $id = 1; $params = array( @@ -231,12 +207,9 @@ require_once 'skipifconnectfailure.inc'; var_dump($label); mysqli_stmt_close($stmt); - if (!$stmt = mysqli_stmt_init($link)) + if (!$stmt = mysqli_prepare($link, 'SELECT id, label FROM test WHERE id = ?')) printf("[035] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test WHERE id = ?')) - printf("[036] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - $id = 1; $params = array( 0 => $stmt, @@ -259,12 +232,9 @@ require_once 'skipifconnectfailure.inc'; var_dump($label); mysqli_stmt_close($stmt); - if (!$stmt = mysqli_stmt_init($link)) + if (!$stmt = mysqli_prepare($link, 'SELECT id, label FROM test WHERE id = ?')) printf("[040] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test WHERE id = ?')) - printf("[041] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - $id = 1; if (!call_user_func_array('mysqli_stmt_bind_param', array($stmt, 'i', &$id))) printf("[042] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); @@ -285,12 +255,9 @@ require_once 'skipifconnectfailure.inc'; // Any of those shall fail - see also bugs.php.net/43568 // mysqli_stmt_close($stmt); - if (!$stmt = mysqli_stmt_init($link)) + if (!$stmt = mysqli_prepare($link, 'SELECT id, label FROM test WHERE id = ?')) printf("[045] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test WHERE id = ?')) - printf("[046] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - $id = 1; $params = array( 0 => 'i', @@ -303,12 +270,9 @@ require_once 'skipifconnectfailure.inc'; printf("[048] [%d] (Message might vary with MySQL Server version, e.g. No data supplied for parameters in prepared statement)\n", mysqli_stmt_errno($stmt)); mysqli_stmt_close($stmt); - if (!$stmt = mysqli_stmt_init($link)) + if (!$stmt = mysqli_prepare($link, 'SELECT id, label FROM test WHERE id = ?')) printf("[049] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test WHERE id = ?')) - printf("[050] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - $id = 1; $params = array( 0 => $stmt, diff --git a/ext/mysqli/tests/mysqli_stmt_bind_param_references.phpt b/ext/mysqli/tests/mysqli_stmt_bind_param_references.phpt index ac02db31d508..0e964aabe0d8 100644 --- a/ext/mysqli/tests/mysqli_stmt_bind_param_references.phpt +++ b/ext/mysqli/tests/mysqli_stmt_bind_param_references.phpt @@ -55,14 +55,13 @@ require_once 'skipifconnectfailure.inc'; // or we will get dups around [28] mysqli_query($link, "ALTER TABLE test DROP PRIMARY KEY"); - $stmt = mysqli_stmt_init($link); - if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) - printf("[001] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!($stmt = mysqli_prepare($link, "INSERT INTO test(id, label) VALUES (?, ?)"))) + printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $id = 100; $label = 'v'; if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label))) - printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + printf("[002] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); if (true !== mysqli_stmt_execute($stmt)) printf("[003] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); diff --git a/ext/mysqli/tests/mysqli_stmt_bind_param_type_juggling.phpt b/ext/mysqli/tests/mysqli_stmt_bind_param_type_juggling.phpt index 887d557a078f..71b059eb579f 100644 --- a/ext/mysqli/tests/mysqli_stmt_bind_param_type_juggling.phpt +++ b/ext/mysqli/tests/mysqli_stmt_bind_param_type_juggling.phpt @@ -24,16 +24,11 @@ require_once 'skipifconnectfailure.inc'; return false; } - if (!$stmt = mysqli_stmt_init($link)) { + if (!$stmt = mysqli_prepare($link, "INSERT INTO test(col1, col2) VALUES (?, ?)")) { printf("[%03d + 3] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link)); return false; } - if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(col1, col2) VALUES (?, ?)")) { - printf("[%03d + 4] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - return false; - } - if (!mysqli_stmt_bind_param($stmt, $bind_type1 . $bind_type2, $bind_value1, $bind_value1)) { printf("[%03d + 5] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); return false; diff --git a/ext/mysqli/tests/mysqli_stmt_bind_result.phpt b/ext/mysqli/tests/mysqli_stmt_bind_result.phpt index d4d61380ff2e..c2aecce1eeb8 100644 --- a/ext/mysqli/tests/mysqli_stmt_bind_result.phpt +++ b/ext/mysqli/tests/mysqli_stmt_bind_result.phpt @@ -10,9 +10,11 @@ require_once 'skipifconnectfailure.inc'; = 50600) func_mysqli_stmt_bind_result($link, $engine, "s", "TIME(6)", "13:31:34.123456", 1770); - $stmt = mysqli_stmt_init($link); - if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (1000, 'z')")) - printf("[3001] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!($stmt = mysqli_prepare($link, "INSERT INTO test(id, label) VALUES (1000, 'z')"))) + printf("[3001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $id = null; try { @@ -288,6 +282,7 @@ require_once 'skipifconnectfailure.inc'; require_once 'clean_table.inc'; ?> --EXPECTF-- +Deprecated: Function mysqli_stmt_init() is deprecated since 8.6, use mysqli_prepare() instead in %s on line %d mysqli_stmt object is not fully initialized Number of bind variables doesn't match number of fields in prepared statement Number of bind variables doesn't match number of fields in prepared statement diff --git a/ext/mysqli/tests/mysqli_stmt_bind_result_bit.phpt b/ext/mysqli/tests/mysqli_stmt_bind_result_bit.phpt index 8000336403a4..4a71f917612a 100644 --- a/ext/mysqli/tests/mysqli_stmt_bind_result_bit.phpt +++ b/ext/mysqli/tests/mysqli_stmt_bind_result_bit.phpt @@ -48,23 +48,11 @@ require_once 'skipifconnectfailure.inc'; // don't bail - column type might not be supported by the server, ignore this continue; } - if (!$stmt_ins = mysqli_stmt_init($link_ins)) { + if (!$stmt_ins = mysqli_prepare($link_ins, "INSERT INTO test(id, bit_value) VALUES (?, ?)")) { printf("[004 - %d] [%d] %s\n", $bits, mysqli_errno($link_ins), mysqli_error($link_ins)); continue; } - if (!mysqli_stmt_prepare($stmt_ins, "INSERT INTO test(id, bit_value) VALUES (?, ?)")) { - printf("[005 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt_ins), mysqli_stmt_error($stmt_ins)); - mysqli_stmt_close($stmt_ins); - continue; - } - - if (!($stmt_sel = mysqli_stmt_init($link_sel))) { - printf("[006 - %d] [%d] %s\n", $bits, mysqli_errno($link_sel), mysqli_error($link_sel)); - mysqli_stmt_close($stmt_ins); - continue; - } - $tests = 0; $rand_max = mt_getrandmax(); while ($tests < 10) { @@ -101,8 +89,12 @@ require_once 'skipifconnectfailure.inc'; break; } $sql = sprintf("SELECT id, BIN(bit_value) AS _bin, bit_value, bit_value + 0 AS _bit_value0, bit_null FROM test WHERE id = %s", $value); - if ((!mysqli_stmt_prepare($stmt_sel, $sql)) || - (!mysqli_stmt_execute($stmt_sel))) { + unset($stmt_sel); // Unset the variable first, otherwise we would get Out of sync error + if (!($stmt_sel = mysqli_prepare($link_sel, $sql))) { + printf("[009 - %d] [%d] %s\n", $bits, mysqli_errno($link_sel), mysqli_error($link_sel)); + break; + } + if (!mysqli_stmt_execute($stmt_sel)) { printf("[009 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt_sel), mysqli_stmt_error($stmt_sel)); break; } diff --git a/ext/mysqli/tests/mysqli_stmt_bind_result_format.phpt b/ext/mysqli/tests/mysqli_stmt_bind_result_format.phpt index a379359b45a8..01503eb29b50 100644 --- a/ext/mysqli/tests/mysqli_stmt_bind_result_format.phpt +++ b/ext/mysqli/tests/mysqli_stmt_bind_result_format.phpt @@ -49,22 +49,15 @@ memory_limit=83886080 function test_format($link, $format, $from, $order_by, $expected, $offset) { - if (!$stmt = mysqli_stmt_init($link)) { - printf("[%03d] Cannot create PS, [%d] %s\n", - $offset, - mysqli_errno($link), mysqli_error($link)); - return false; - } - if ($order_by) $sql = sprintf('SELECT %s AS _format FROM %s ORDER BY %s', $format, $from, $order_by); else $sql = sprintf('SELECT %s AS _format FROM %s', $format, $from); - if (!mysqli_stmt_prepare($stmt, $sql)) { + if (!$stmt = mysqli_prepare($link, $sql)) { printf("[%03d] Cannot prepare PS, [%d] %s\n", $offset + 1, - mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + mysqli_errno($link), mysqli_error($link)); return false; } @@ -244,16 +237,11 @@ memory_limit=83886080 } krsort($values); - if (!$stmt = mysqli_stmt_init($link)) { + if (!$stmt = mysqli_prepare($link, 'SELECT trend, targetport, FORMAT(trend, 2) FROM test WHERE current_targets > 0 AND trend IS NOT NULL ORDER BY trend DESC LIMIT 100')) { printf("[302] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); break; } - if (!mysqli_stmt_prepare($stmt, 'SELECT trend, targetport, FORMAT(trend, 2) FROM test WHERE current_targets > 0 AND trend IS NOT NULL ORDER BY trend DESC LIMIT 100')) { - printf("[303] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link)); - break; - } - if (!mysqli_stmt_execute($stmt)) { printf("[304] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link)); break; @@ -284,16 +272,11 @@ memory_limit=83886080 mysqli_stmt_close($stmt); // same but OO interface - if (!$stmt = mysqli_stmt_init($link)) { + if (!$stmt = $link->prepare('SELECT trend, targetport, FORMAT(trend, 2) FROM test WHERE current_targets > 0 AND trend IS NOT NULL ORDER BY trend DESC LIMIT 100')) { printf("[307] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); break; } - if (!$stmt->prepare('SELECT trend, targetport, FORMAT(trend, 2) FROM test WHERE current_targets > 0 AND trend IS NOT NULL ORDER BY trend DESC LIMIT 100')) { - printf("[308] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link)); - break; - } - if (!$stmt->execute()) { printf("[309] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link)); break; diff --git a/ext/mysqli/tests/mysqli_stmt_bind_result_references.phpt b/ext/mysqli/tests/mysqli_stmt_bind_result_references.phpt index a7cef70a5308..ba95c382a084 100644 --- a/ext/mysqli/tests/mysqli_stmt_bind_result_references.phpt +++ b/ext/mysqli/tests/mysqli_stmt_bind_result_references.phpt @@ -10,12 +10,8 @@ require_once 'skipifconnectfailure.inc'; getMessage() . "\n"; } - if (!$stmt = mysqli_stmt_init($link)) + if (!$stmt = mysqli_prepare($link, "INSERT INTO test(id, label) VALUES (?, ?)")) printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) - printf("[009] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - $id = $label = null; if (!mysqli_stmt_bind_param($stmt, "is", $id, $label)) printf("[010] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); @@ -52,12 +48,9 @@ require_once 'skipifconnectfailure.inc'; mysqli_close($link); require 'table.inc'; - if (!$stmt = mysqli_stmt_init($link)) + if (!$stmt = mysqli_prepare($link, "SELECT id, label FROM test")) printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test")) - printf("[014] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - $id = $label = null; if (!mysqli_stmt_bind_result($stmt, $id, $label)) printf("[015] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); @@ -75,7 +68,8 @@ require_once 'skipifconnectfailure.inc'; ---EXPECT-- +--EXPECTF-- +Deprecated: Function mysqli_stmt_init() is deprecated since 8.6, use mysqli_prepare() instead in %s on line %d mysqli_stmt object is not fully initialized mysqli_stmt object is already closed done! diff --git a/ext/mysqli/tests/mysqli_stmt_data_seek.phpt b/ext/mysqli/tests/mysqli_stmt_data_seek.phpt index e4b913229cd0..c141b6242fa6 100644 --- a/ext/mysqli/tests/mysqli_stmt_data_seek.phpt +++ b/ext/mysqli/tests/mysqli_stmt_data_seek.phpt @@ -85,7 +85,8 @@ require_once 'skipifconnectfailure.inc'; ---EXPECT-- +--EXPECTF-- +Deprecated: Function mysqli_stmt_init() is deprecated since 8.6, use mysqli_prepare() instead in %s on line %d mysqli_stmt object is not fully initialized mysqli_stmt_data_seek(): No result set associated with the statement int(3) diff --git a/ext/mysqli/tests/mysqli_stmt_errno.phpt b/ext/mysqli/tests/mysqli_stmt_errno.phpt index 09df91044ab4..cb5d796b4819 100644 --- a/ext/mysqli/tests/mysqli_stmt_errno.phpt +++ b/ext/mysqli/tests/mysqli_stmt_errno.phpt @@ -55,6 +55,7 @@ require_once 'skipifconnectfailure.inc'; ---EXPECT-- +--EXPECTF-- +Deprecated: Function mysqli_stmt_init() is deprecated since 8.6, use mysqli_prepare() instead in %s on line %d mysqli_stmt object is already closed done! diff --git a/ext/mysqli/tests/mysqli_stmt_error.phpt b/ext/mysqli/tests/mysqli_stmt_error.phpt index 35ee69550c08..1a2a648f2f6f 100644 --- a/ext/mysqli/tests/mysqli_stmt_error.phpt +++ b/ext/mysqli/tests/mysqli_stmt_error.phpt @@ -55,6 +55,7 @@ require_once 'skipifconnectfailure.inc'; ---EXPECT-- +--EXPECTF-- +Deprecated: Function mysqli_stmt_init() is deprecated since 8.6, use mysqli_prepare() instead in %s on line %d mysqli_stmt object is already closed done! diff --git a/ext/mysqli/tests/mysqli_stmt_execute.phpt b/ext/mysqli/tests/mysqli_stmt_execute.phpt index 2f8dc2f288c9..ae1cec231610 100644 --- a/ext/mysqli/tests/mysqli_stmt_execute.phpt +++ b/ext/mysqli/tests/mysqli_stmt_execute.phpt @@ -54,12 +54,9 @@ require_once 'skipifconnectfailure.inc'; // calling reset between executions mysqli_stmt_close($stmt); - if (!$stmt = mysqli_stmt_init($link)) + if (!$stmt = mysqli_prepare($link, "SELECT id FROM test ORDER BY id LIMIT ?")) printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!mysqli_stmt_prepare($stmt, "SELECT id FROM test ORDER BY id LIMIT ?")) - printf("[014] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - $limit = 1; if (!mysqli_stmt_bind_param($stmt, "i", $limit)) printf("[015] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); @@ -91,12 +88,9 @@ require_once 'skipifconnectfailure.inc'; printf("[022] Expecting int/1 got %s/%s\n", gettype($id), $id); mysqli_stmt_close($stmt); - if (!$stmt = mysqli_stmt_init($link)) + if (!$stmt = mysqli_prepare($link, "SELECT id FROM test ORDER BY id LIMIT 1")) printf("[023] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!mysqli_stmt_prepare($stmt, "SELECT id FROM test ORDER BY id LIMIT 1")) - printf("[024] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (true !== ($tmp = mysqli_stmt_execute($stmt))) printf("[025] Expecting boolean/true, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); @@ -128,7 +122,8 @@ require_once 'skipifconnectfailure.inc'; ---EXPECT-- +--EXPECTF-- +Deprecated: Function mysqli_stmt_init() is deprecated since 8.6, use mysqli_prepare() instead in %s on line %d mysqli_stmt object is not fully initialized mysqli_stmt object is not fully initialized bool(true) diff --git a/ext/mysqli/tests/mysqli_stmt_fetch.phpt b/ext/mysqli/tests/mysqli_stmt_fetch.phpt index 7c5fb22574e1..925d8b27b481 100644 --- a/ext/mysqli/tests/mysqli_stmt_fetch.phpt +++ b/ext/mysqli/tests/mysqli_stmt_fetch.phpt @@ -39,12 +39,9 @@ require_once 'skipifconnectfailure.inc'; printf("[008] NULL, got %s/%s\n", gettype($tmp), $tmp); mysqli_stmt_close($stmt); - if (!$stmt = mysqli_stmt_init($link)) + if (!$stmt = mysqli_prepare($link, "SELECT id, label FROM test ORDER BY id LIMIT 2")) printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 2")) - printf("[010] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (!mysqli_stmt_execute($stmt)) printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); @@ -80,6 +77,7 @@ require_once 'skipifconnectfailure.inc'; require_once 'clean_table.inc'; ?> --EXPECTF-- +Deprecated: Function mysqli_stmt_init() is deprecated since 8.6, use mysqli_prepare() instead in %s on line %d mysqli_stmt object is not fully initialized [014] [%d] Commands out of sync; you can't run this command now mysqli_stmt object is already closed diff --git a/ext/mysqli/tests/mysqli_stmt_fetch_bit.phpt b/ext/mysqli/tests/mysqli_stmt_fetch_bit.phpt index 325314f50035..b2ed038dd815 100644 --- a/ext/mysqli/tests/mysqli_stmt_fetch_bit.phpt +++ b/ext/mysqli/tests/mysqli_stmt_fetch_bit.phpt @@ -29,16 +29,16 @@ if (mysqli_get_server_version($link) < 50003) { !mysqli_query($link, $sql = sprintf('CREATE TABLE test(id INT, label BIT(%d)) ENGINE="%s"', $bits, $engine))) printf("[002 - %d] [%d] %s\n",$bits, mysqli_errno($link), mysqli_error($link)); - if (!$stmt = mysqli_stmt_init($link)) - printf("[003 - %d] [%d] %s\n", $bits, mysqli_errno($link), mysqli_error($link)); - while ($tests < min($max_value, 20)) { $tests++; $value = mt_rand(0, $max_value); $sql = sprintf("INSERT INTO test(id, label) VALUES (%d, b'%s')", $value, decbin($value)); - if (!mysqli_stmt_prepare($stmt, $sql) || - !mysqli_stmt_execute($stmt)) + unset($stmt); // Unset the variable first, otherwise we would get Out of sync error + if (!$stmt = mysqli_prepare($link, $sql)) + printf("[003 - %d] [%d] %s\n", $bits, mysqli_errno($link), mysqli_error($link)); + + if (!mysqli_stmt_execute($stmt)) printf("[004 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); $id = $_label0 = $label = null; diff --git a/ext/mysqli/tests/mysqli_stmt_fetch_fields_win32_unicode.phpt b/ext/mysqli/tests/mysqli_stmt_fetch_fields_win32_unicode.phpt index 90348833e57f..07d2d2ac334c 100644 --- a/ext/mysqli/tests/mysqli_stmt_fetch_fields_win32_unicode.phpt +++ b/ext/mysqli/tests/mysqli_stmt_fetch_fields_win32_unicode.phpt @@ -12,8 +12,7 @@ require_once 'skipifconnectfailure.inc'; require_once 'table.inc'; $bind_res = $id = null; - if (!($stmt = mysqli_stmt_init($link)) || - !mysqli_stmt_prepare($stmt, "SELECT id, label FROM test") || + if (!($stmt = mysqli_prepare($link, "SELECT id, label FROM test")) || !mysqli_stmt_execute($stmt) || !($result = mysqli_stmt_result_metadata($stmt)) || !mysqli_stmt_bind_result($stmt, $id, $bind_res) || @@ -26,8 +25,7 @@ require_once 'skipifconnectfailure.inc'; mysqli_free_result($result); mysqli_stmt_close($stmt); - if (!($stmt = mysqli_stmt_init($link)) || - !mysqli_stmt_prepare($stmt, "SELECT id, label FROM test") || + if (!($stmt = mysqli_prepare($link, "SELECT id, label FROM test")) || !mysqli_stmt_execute($stmt) || !($result = mysqli_stmt_result_metadata($stmt)) || !mysqli_stmt_bind_result($stmt, $id, $bind_res)) { diff --git a/ext/mysqli/tests/mysqli_stmt_fetch_geom.phpt b/ext/mysqli/tests/mysqli_stmt_fetch_geom.phpt index 9191df87ac7c..944133835396 100644 --- a/ext/mysqli/tests/mysqli_stmt_fetch_geom.phpt +++ b/ext/mysqli/tests/mysqli_stmt_fetch_geom.phpt @@ -34,17 +34,11 @@ mysqli } } - if (!$stmt = mysqli_stmt_init($link)) { + if (!$stmt = mysqli_prepare($link, "SELECT id, label FROM test")) { printf("[%04d] [%d] %s\n", $offset + 6, mysqli_errno($link), mysqli_error($link)); return false; } - if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test")) { - printf("[%04d] [%d] %s\n", $offset + 7, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - mysqli_stmt_close($stmt); - return false; - } - if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_store_result($stmt)) { printf("[%04d] [%d] %s\n", $offset + 8, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); mysqli_stmt_close($stmt); @@ -78,16 +72,11 @@ mysqli mysqli_stmt_close($stmt); foreach ($rows as $row) { - if (!$stmt = mysqli_stmt_init($link)) { + if (!$stmt = mysqli_prepare($link, "INSERT INTO test(id, label) VALUES (?, ?)")) { printf("[%04d] [%d] %s\n", $offset + 10, mysqli_errno($link), mysqli_error($link)); return false; } - if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) { - printf("[%04d] [%d] %s\n", $offset + 11, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - return false; - } - $new_id = $row['id'] + 10; if (!mysqli_stmt_bind_param($stmt, "is", $new_id, $row['label'])) { printf("[%04d] [%d] %s\n", $offset + 12, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); diff --git a/ext/mysqli/tests/mysqli_stmt_field_count.phpt b/ext/mysqli/tests/mysqli_stmt_field_count.phpt index 6b4bd5d82252..06281271beb5 100644 --- a/ext/mysqli/tests/mysqli_stmt_field_count.phpt +++ b/ext/mysqli/tests/mysqli_stmt_field_count.phpt @@ -93,7 +93,8 @@ require_once 'skipifconnectfailure.inc'; ---EXPECT-- +--EXPECTF-- +Deprecated: Function mysqli_stmt_init() is deprecated since 8.6, use mysqli_prepare() instead in %s on line %d mysqli_stmt object is not fully initialized mysqli_stmt object is not fully initialized The number of variables must match the number of parameters in the prepared statement diff --git a/ext/mysqli/tests/mysqli_stmt_free_result.phpt b/ext/mysqli/tests/mysqli_stmt_free_result.phpt index d512a23ee037..ceadeec4236d 100644 --- a/ext/mysqli/tests/mysqli_stmt_free_result.phpt +++ b/ext/mysqli/tests/mysqli_stmt_free_result.phpt @@ -40,12 +40,9 @@ require_once 'skipifconnectfailure.inc'; mysqli_stmt_close($stmt); - if (!$stmt = mysqli_stmt_init($link)) + if (!$stmt = mysqli_prepare($link, "SELECT id, label FROM test ORDER BY id")) printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id")) - printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (!mysqli_stmt_execute($stmt)) printf("[012] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); @@ -70,7 +67,8 @@ require_once 'skipifconnectfailure.inc'; ---EXPECT-- +--EXPECTF-- +Deprecated: Function mysqli_stmt_init() is deprecated since 8.6, use mysqli_prepare() instead in %s on line %d mysqli_stmt object is not fully initialized mysqli_stmt object is already closed done! diff --git a/ext/mysqli/tests/mysqli_stmt_get_result.phpt b/ext/mysqli/tests/mysqli_stmt_get_result.phpt index 06f18aaa4718..39290b352f3f 100644 --- a/ext/mysqli/tests/mysqli_stmt_get_result.phpt +++ b/ext/mysqli/tests/mysqli_stmt_get_result.phpt @@ -104,12 +104,9 @@ require_once 'skipifconnectfailure.inc'; mysqli_stmt_close($stmt); // get_result can be used in PS cursor mode - if (!$stmt = mysqli_stmt_init($link)) + if (!$stmt = mysqli_prepare($link, "SELECT id, label FROM test ORDER BY id LIMIT 2")) printf("[030] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 2")) - printf("[031] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (!mysqli_stmt_attr_set($stmt, MYSQLI_STMT_ATTR_CURSOR_TYPE, MYSQLI_CURSOR_TYPE_READ_ONLY)) printf("[032] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); @@ -121,12 +118,9 @@ require_once 'skipifconnectfailure.inc'; var_dump($row); } - if (!$stmt = mysqli_stmt_init($link)) + if (!$stmt = mysqli_prepare($link, "SELECT id, label FROM test ORDER BY id LIMIT 2")) printf("[034] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 2")) - printf("[035] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (!mysqli_stmt_execute($stmt)) printf("[036] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); @@ -176,8 +170,13 @@ require_once 'skipifconnectfailure.inc'; require_once 'clean_table.inc'; ?> --EXPECTF-- +Deprecated: Function mysqli_stmt_init() is deprecated since 8.6, use mysqli_prepare() instead in %s on line %d mysqli_stmt object is not fully initialized + +Deprecated: Function mysqli_stmt_init() is deprecated since 8.6, use mysqli_prepare() instead in %s on line %d mysqli_stmt object is not fully initialized + +Deprecated: Function mysqli_stmt_init() is deprecated since 8.6, use mysqli_prepare() instead in %s on line %d mysqli_stmt object is not fully initialized array(2) { ["id"]=> diff --git a/ext/mysqli/tests/mysqli_stmt_get_result2.phpt b/ext/mysqli/tests/mysqli_stmt_get_result2.phpt index 5178d2b60975..a9bffcca0422 100644 --- a/ext/mysqli/tests/mysqli_stmt_get_result2.phpt +++ b/ext/mysqli/tests/mysqli_stmt_get_result2.phpt @@ -15,44 +15,42 @@ require_once 'skipifconnectfailure.inc'; */ require 'table.inc'; - if (!$stmt = mysqli_stmt_init($link)) + if (!$stmt = mysqli_prepare($link, "SELECT id, label FROM test ORDER BY id ASC LIMIT 1")) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id ASC LIMIT 1")) - printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - if (!mysqli_stmt_execute($stmt)) - printf("[006] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - if (!is_object($res = mysqli_stmt_get_result($stmt)) || 'mysqli_result' != get_class($res)) { - printf("[007] Expecting object/mysqli_result got %s/%s, [%d] %s\n", - gettype($res), $res, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - } - while ($row = mysqli_fetch_assoc($res)) - var_dump($row); - var_dump(mysqli_fetch_assoc($res)); - mysqli_free_result($res); - - if (false !== ($res = mysqli_stmt_get_result($stmt))) { - printf("[008] boolean/false got %s/%s, [%d] %s\n", - gettype($res), $res, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - } - - mysqli_stmt_execute($stmt); - if (!is_object($res = mysqli_stmt_get_result($stmt)) || 'mysqli_result' != get_class($res)) { - printf("[009] Expecting object/mysqli_result got %s/%s, [%d] %s\n", - gettype($res), $res, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - } - while ($row = mysqli_fetch_assoc($res)) - var_dump($row); - var_dump(mysqli_fetch_assoc($res)); - mysqli_free_result($res); + if (!mysqli_stmt_execute($stmt)) + printf("[006] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + if (!is_object($res = mysqli_stmt_get_result($stmt)) || 'mysqli_result' != get_class($res)) { + printf("[007] Expecting object/mysqli_result got %s/%s, [%d] %s\n", + gettype($res), $res, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + } + while ($row = mysqli_fetch_assoc($res)) + var_dump($row); + var_dump(mysqli_fetch_assoc($res)); + mysqli_free_result($res); + + if (false !== ($res = mysqli_stmt_get_result($stmt))) { + printf("[008] boolean/false got %s/%s, [%d] %s\n", + gettype($res), $res, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + } + + mysqli_stmt_execute($stmt); + if (!is_object($res = mysqli_stmt_get_result($stmt)) || 'mysqli_result' != get_class($res)) { + printf("[009] Expecting object/mysqli_result got %s/%s, [%d] %s\n", + gettype($res), $res, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + } + while ($row = mysqli_fetch_assoc($res)) + var_dump($row); + var_dump(mysqli_fetch_assoc($res)); + mysqli_free_result($res); mysqli_stmt_close($stmt); - if (!($stmt = mysqli_stmt_init($link)) || - !mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id ASC LIMIT 2") || - !mysqli_stmt_execute($stmt)) + if (!$stmt = mysqli_prepare($link, "SELECT id, label FROM test ORDER BY id ASC LIMIT 2")) + printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!mysqli_stmt_execute($stmt)) printf("[010] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); $id = $label = null; @@ -69,9 +67,10 @@ require_once 'skipifconnectfailure.inc'; mysqli_stmt_close($stmt); - if (!($stmt = mysqli_stmt_init($link)) || - !mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id ASC LIMIT 2") || - !mysqli_stmt_execute($stmt)) + if (!$stmt = mysqli_prepare($link, "SELECT id, label FROM test ORDER BY id ASC LIMIT 2")) + printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!mysqli_stmt_execute($stmt)) printf("[014] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!is_object($res = mysqli_stmt_get_result($stmt)) || 'mysqli_result' != get_class($res)) { @@ -88,9 +87,10 @@ require_once 'skipifconnectfailure.inc'; mysqli_stmt_close($stmt); - if (!($stmt = mysqli_stmt_init($link)) || - !mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id ASC LIMIT 2") || - !mysqli_stmt_execute($stmt)) + if (!$stmt = mysqli_prepare($link, "SELECT id, label FROM test ORDER BY id ASC LIMIT 2")) + printf("[018] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!mysqli_stmt_execute($stmt)) printf("[018] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!is_object($res = mysqli_stmt_get_result($stmt)) || 'mysqli_result' != get_class($res)) { @@ -109,9 +109,10 @@ require_once 'skipifconnectfailure.inc'; mysqli_stmt_close($stmt); - if (!($stmt = mysqli_stmt_init($link)) || - !mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id ASC LIMIT 2") || - !mysqli_stmt_execute($stmt)) + if (!$stmt = mysqli_prepare($link, "SELECT id, label FROM test ORDER BY id ASC LIMIT 2")) + printf("[022] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!mysqli_stmt_execute($stmt)) printf("[022] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!is_object($res = mysqli_stmt_get_result($stmt)) || 'mysqli_result' != get_class($res)) { diff --git a/ext/mysqli/tests/mysqli_stmt_get_result_bit.phpt b/ext/mysqli/tests/mysqli_stmt_get_result_bit.phpt index ae21ef2ad286..367975172eb0 100644 --- a/ext/mysqli/tests/mysqli_stmt_get_result_bit.phpt +++ b/ext/mysqli/tests/mysqli_stmt_get_result_bit.phpt @@ -47,9 +47,6 @@ if (mysqli_get_server_version($link) < 50003) { !mysqli_query($link, $sql = sprintf('CREATE TABLE test(id BIGINT UNSIGNED, bit_value BIT(%d) NOT NULL, bit_null BIT(%d) DEFAULT NULL) ENGINE="%s"', $bits, $bits, $engine))) printf("[002 - %d] [%d] %s\n",$bits, mysqli_errno($link), mysqli_error($link)); - if (!$stmt = mysqli_stmt_init($link)) - printf("[003 - %d] [%d] %s\n", $bits, mysqli_errno($link), mysqli_error($link)); - $tests = 0; $rand_max = mt_getrandmax(); while ($tests < 10) { @@ -77,13 +74,17 @@ if (mysqli_get_server_version($link) < 50003) { ; $bin2 = substr($bin, $i, strlen($bin)); - if (!mysqli_stmt_prepare($stmt, $sql) || - !mysqli_stmt_execute($stmt)) + if (!$stmt = mysqli_prepare($link, $sql)) + printf("[003 - %d] [%d] %s\n", $bits, mysqli_errno($link), mysqli_error($link)); + + if(!mysqli_stmt_execute($stmt)) printf("[004 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); $sql = sprintf("SELECT bin(bit_value) AS _bin, id, bit_value, bit_null FROM test WHERE id = %s", $value); - if (!mysqli_stmt_prepare($stmt, $sql) || - !mysqli_stmt_execute($stmt)) + if (!$stmt = mysqli_prepare($link, $sql)) + printf("[005 - %d] [%d] %s\n", $bits, mysqli_errno($link), mysqli_error($link)); + + if(!mysqli_stmt_execute($stmt)) printf("[005 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); if (!$res = mysqli_stmt_get_result($stmt)) diff --git a/ext/mysqli/tests/mysqli_stmt_get_result_field_count.phpt b/ext/mysqli/tests/mysqli_stmt_get_result_field_count.phpt index bc5bfea1b29e..d42d9b43bcf1 100644 --- a/ext/mysqli/tests/mysqli_stmt_get_result_field_count.phpt +++ b/ext/mysqli/tests/mysqli_stmt_get_result_field_count.phpt @@ -10,12 +10,9 @@ mysqli prepare('SHOW ENGINES') || - !$stmt->execute()) + if (!$stmt = mysqli_prepare($link, "SHOW ENGINES")) + printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!$stmt->execute()) printf("[002] [%d] %s\n", $stmt->errno, $stmt->error); if (!$res = $stmt->get_result()) @@ -48,8 +47,10 @@ require_once 'skipifconnectfailure.inc'; if (mysqli_query($link, 'PREPARE mystmt FROM "DESCRIBE test id"')) { mysqli_query($link, 'DEALLOCATE PREPARE mystmt'); - if (!$stmt->prepare('DESCRIBE test id') || - !$stmt->execute()) + if (!$stmt = mysqli_prepare($link, "DESCRIBE test id")) + printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!mysqli_stmt_execute($stmt)) printf("[006] [%d] %s\n", $stmt->errno, $stmt->error); if (!$res = $stmt->get_result()) @@ -67,8 +68,10 @@ require_once 'skipifconnectfailure.inc'; if (mysqli_query($link, 'PREPARE mystmt FROM "EXPLAIN SELECT id FROM test"')) { mysqli_query($link, 'DEALLOCATE PREPARE mystmt'); - if (!$stmt->prepare('EXPLAIN SELECT id FROM test') || - !$stmt->execute()) + if (!$stmt = mysqli_prepare($link, "EXPLAIN SELECT id FROM test")) + printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!$stmt->execute()) printf("[009] [%d] %s\n", $stmt->errno, $stmt->error); if (!$res = $stmt->get_result()) diff --git a/ext/mysqli/tests/mysqli_stmt_get_result_seek.phpt b/ext/mysqli/tests/mysqli_stmt_get_result_seek.phpt index 987d1b2c082e..2fd6f45b7abc 100644 --- a/ext/mysqli/tests/mysqli_stmt_get_result_seek.phpt +++ b/ext/mysqli/tests/mysqli_stmt_get_result_seek.phpt @@ -10,11 +10,8 @@ require_once 'skipifconnectfailure.inc'; 0; $i--) { if (!$res->data_seek($i)) printf("[007] Cannot seek to position %d, [%d] %s\n", - $i, mysqli_stmt_errno($stmt), $stmt->error); + $i, mysqli_errno($link), mysqli_error($link)); $row = $res->fetch_array(MYSQLI_BOTH); if (($row[0] !== $row['id']) || ($row[0] !== $i + 1)) { printf("[008] Record looks wrong, dumping data\n"); diff --git a/ext/mysqli/tests/mysqli_stmt_get_result_types.phpt b/ext/mysqli/tests/mysqli_stmt_get_result_types.phpt index f49c2079f72e..956fc9e222cb 100644 --- a/ext/mysqli/tests/mysqli_stmt_get_result_types.phpt +++ b/ext/mysqli/tests/mysqli_stmt_get_result_types.phpt @@ -24,13 +24,8 @@ mysqli return false; } - if (!$stmt = mysqli_stmt_init($link)) { - printf("[%04d] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link)); - return false; - } - - if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) { - printf("[%04d] [%d] %s\n", $offset + 2, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!$stmt = mysqli_prepare($link, "INSERT INTO test(id, label) VALUES (?, ?)")) { + printf("[%04d] [%d] %s\n", $offset + 2, mysqli_errno($link), mysqli_error($link)); return false; } @@ -48,10 +43,8 @@ mysqli } mysqli_stmt_close($stmt); - $stmt = mysqli_stmt_init($link); - - if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test")) { - printf("[%04d] [%d] %s\n", $offset + 7, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!($stmt = mysqli_prepare($link, "SELECT id, label FROM test"))) { + printf("[%04d] [%d] %s\n", $offset + 7, mysqli_errno($link), mysqli_error($link)); return false; } diff --git a/ext/mysqli/tests/mysqli_stmt_get_warnings.phpt b/ext/mysqli/tests/mysqli_stmt_get_warnings.phpt index 86bd19da71ca..e000a840260a 100644 --- a/ext/mysqli/tests/mysqli_stmt_get_warnings.phpt +++ b/ext/mysqli/tests/mysqli_stmt_get_warnings.phpt @@ -95,7 +95,8 @@ mysqli_query($link, "DROP TABLE IF EXISTS test"); ---EXPECT-- +--EXPECTF-- +Deprecated: Function mysqli_stmt_init() is deprecated since 8.6, use mysqli_prepare() instead in %s on line %d mysqli_stmt object is not fully initialized mysqli_stmt object is already closed done! diff --git a/ext/mysqli/tests/mysqli_stmt_init.phpt b/ext/mysqli/tests/mysqli_stmt_init.phpt index 38f5dcb25e4a..875ac806684b 100644 --- a/ext/mysqli/tests/mysqli_stmt_init.phpt +++ b/ext/mysqli/tests/mysqli_stmt_init.phpt @@ -20,10 +20,13 @@ require_once 'skipifconnectfailure.inc'; exit(1); } + if (!is_object($stmt = $link->stmt_init())) + printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!is_object($stmt = mysqli_stmt_init($link))) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!is_object($stmt2 = @mysqli_stmt_init($link))) + if (!is_object($stmt2 = mysqli_stmt_init($link))) printf("[003a] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); try { @@ -42,7 +45,14 @@ require_once 'skipifconnectfailure.inc'; print "done!"; ?> ---EXPECT-- +--EXPECTF-- +Deprecated: Method mysqli::stmt_init() is deprecated since 8.6, use mysqli::prepare() instead in %s on line %d + +Deprecated: Function mysqli_stmt_init() is deprecated since 8.6, use mysqli_prepare() instead in %s on line %d + +Deprecated: Function mysqli_stmt_init() is deprecated since 8.6, use mysqli_prepare() instead in %s on line %d mysqli_stmt object is not fully initialized + +Deprecated: Function mysqli_stmt_init() is deprecated since 8.6, use mysqli_prepare() instead in %s on line %d mysqli object is already closed done! diff --git a/ext/mysqli/tests/mysqli_stmt_insert_id.phpt b/ext/mysqli/tests/mysqli_stmt_insert_id.phpt index 044b2b1e5ead..125c3d4d294f 100644 --- a/ext/mysqli/tests/mysqli_stmt_insert_id.phpt +++ b/ext/mysqli/tests/mysqli_stmt_insert_id.phpt @@ -28,9 +28,11 @@ require_once 'skipifconnectfailure.inc'; mysqli_stmt_close($stmt); // no auto_increment column - $stmt = mysqli_stmt_init($link); - if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (100, 'a')") || - !mysqli_stmt_execute($stmt)) { + if(!$stmt = mysqli_prepare($link, "INSERT INTO test(id, label) VALUES (100, 'a')")) { + printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + + if (!mysqli_stmt_execute($stmt)) { printf("[006] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); } @@ -67,7 +69,8 @@ require_once 'skipifconnectfailure.inc'; ---EXPECT-- +--EXPECTF-- +Deprecated: Function mysqli_stmt_init() is deprecated since 8.6, use mysqli_prepare() instead in %s on line %d mysqli_stmt object is not fully initialized mysqli_stmt object is already closed done! diff --git a/ext/mysqli/tests/mysqli_stmt_num_rows.phpt b/ext/mysqli/tests/mysqli_stmt_num_rows.phpt index d3a73fa283d3..886d4552b05f 100644 --- a/ext/mysqli/tests/mysqli_stmt_num_rows.phpt +++ b/ext/mysqli/tests/mysqli_stmt_num_rows.phpt @@ -103,7 +103,8 @@ require_once 'skipifconnectfailure.inc'; ---EXPECT-- +--EXPECTF-- +Deprecated: Function mysqli_stmt_init() is deprecated since 8.6, use mysqli_prepare() instead in %s on line %d run_tests.php don't fool me with your 'ungreedy' expression '.+?'! mysqli_stmt object is already closed done! diff --git a/ext/mysqli/tests/mysqli_stmt_param_count.phpt b/ext/mysqli/tests/mysqli_stmt_param_count.phpt index 11d99addcb5a..8f309c90ab08 100644 --- a/ext/mysqli/tests/mysqli_stmt_param_count.phpt +++ b/ext/mysqli/tests/mysqli_stmt_param_count.phpt @@ -54,7 +54,8 @@ require_once 'skipifconnectfailure.inc'; ---EXPECT-- +--EXPECTF-- +Deprecated: Function mysqli_stmt_init() is deprecated since 8.6, use mysqli_prepare() instead in %s on line %d mysqli_stmt object is not fully initialized mysqli_stmt object is already closed done! diff --git a/ext/mysqli/tests/mysqli_stmt_prepare.phpt b/ext/mysqli/tests/mysqli_stmt_prepare.phpt index 5c6db7ebf5c7..9bc6cccdff00 100644 --- a/ext/mysqli/tests/mysqli_stmt_prepare.phpt +++ b/ext/mysqli/tests/mysqli_stmt_prepare.phpt @@ -16,7 +16,7 @@ require_once 'skipifconnectfailure.inc'; require 'table.inc'; - if (!$stmt = mysqli_stmt_init($link)) + if (!$stmt = mysqli_prepare($link, 'DO 1')) printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (false !== ($tmp = mysqli_stmt_prepare($stmt, ''))) diff --git a/ext/mysqli/tests/mysqli_stmt_reset.phpt b/ext/mysqli/tests/mysqli_stmt_reset.phpt index d96c3114a160..e184a74f3b2e 100644 --- a/ext/mysqli/tests/mysqli_stmt_reset.phpt +++ b/ext/mysqli/tests/mysqli_stmt_reset.phpt @@ -44,8 +44,6 @@ require_once 'skipifconnectfailure.inc'; var_dump($id); mysqli_stmt_close($stmt); - if (!$stmt = mysqli_stmt_init($link)) - printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); @@ -53,8 +51,8 @@ require_once 'skipifconnectfailure.inc'; if (!mysqli_query($link, "CREATE TABLE test(id INT NOT NULL AUTO_INCREMENT, label BLOB, PRIMARY KEY(id))")) printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(label) VALUES (?)")) - printf("[013] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!($stmt = mysqli_prepare($link, "INSERT INTO test(label) VALUES (?)"))) + printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $label = null; if (!mysqli_stmt_bind_param($stmt, "b", $label)) @@ -98,7 +96,8 @@ require_once 'skipifconnectfailure.inc'; ---EXPECT-- +--EXPECTF-- +Deprecated: Function mysqli_stmt_init() is deprecated since 8.6, use mysqli_prepare() instead in %s on line %d mysqli_stmt object is not fully initialized int(1) mysqli_stmt object is already closed diff --git a/ext/mysqli/tests/mysqli_stmt_result_metadata.phpt b/ext/mysqli/tests/mysqli_stmt_result_metadata.phpt index 8d73967777a6..afe923c6cf91 100644 --- a/ext/mysqli/tests/mysqli_stmt_result_metadata.phpt +++ b/ext/mysqli/tests/mysqli_stmt_result_metadata.phpt @@ -86,6 +86,7 @@ require_once 'skipifconnectfailure.inc'; require_once 'clean_table.inc'; ?> --EXPECTF-- +Deprecated: Function mysqli_stmt_init() is deprecated since 8.6, use mysqli_prepare() instead in %s on line %d mysqli_stmt object is not fully initialized object(stdClass)#%d (13) { ["name"]=> diff --git a/ext/mysqli/tests/mysqli_stmt_send_long_data.phpt b/ext/mysqli/tests/mysqli_stmt_send_long_data.phpt index dbf8dddb88e4..b99d9d16947c 100644 --- a/ext/mysqli/tests/mysqli_stmt_send_long_data.phpt +++ b/ext/mysqli/tests/mysqli_stmt_send_long_data.phpt @@ -11,17 +11,14 @@ require_once 'skipifconnectfailure.inc'; ---EXPECT-- +--EXPECTF-- +Deprecated: Function mysqli_stmt_init() is deprecated since 8.6, use mysqli_prepare() instead in %s on line %d mysqli_stmt object is not fully initialized mysqli_stmt object is already closed done! diff --git a/ext/mysqli/tests/mysqli_stmt_store_result.phpt b/ext/mysqli/tests/mysqli_stmt_store_result.phpt index 6ebb10823566..7b4f46767e26 100644 --- a/ext/mysqli/tests/mysqli_stmt_store_result.phpt +++ b/ext/mysqli/tests/mysqli_stmt_store_result.phpt @@ -34,11 +34,10 @@ require_once 'skipifconnectfailure.inc'; if (!$link_buf = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[009] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); - if (!$stmt_buf = mysqli_stmt_init($link_buf)) + if (!$stmt_buf = mysqli_prepare($link_buf, "SELECT id, label FROM test ORDER BY id")) printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!mysqli_stmt_prepare($stmt_buf, "SELECT id, label FROM test ORDER BY id") || - !mysqli_stmt_execute($stmt_buf)) + if (!mysqli_stmt_execute($stmt_buf)) printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt_buf), mysqli_stmt_error($stmt_buf)); $id = $label = $id_buf = $label_buf = null; @@ -78,7 +77,8 @@ require_once 'skipifconnectfailure.inc'; ---EXPECT-- +--EXPECTF-- +Deprecated: Function mysqli_stmt_init() is deprecated since 8.6, use mysqli_prepare() instead in %s on line %d mysqli_stmt object is not fully initialized mysqli_stmt object is already closed done! diff --git a/ext/mysqli/tests/mysqli_stmt_unclonable.phpt b/ext/mysqli/tests/mysqli_stmt_unclonable.phpt index c1e01d37e36c..2c71e7e9786e 100644 --- a/ext/mysqli/tests/mysqli_stmt_unclonable.phpt +++ b/ext/mysqli/tests/mysqli_stmt_unclonable.phpt @@ -14,7 +14,7 @@ require_once 'skipifconnectfailure.inc'; printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); - if (!$stmt = mysqli_stmt_init($link)) + if (!$stmt = mysqli_prepare($link, "DO 1")) printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); try { diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c index 4d3081a3b076..468055732e14 100644 --- a/ext/odbc/php_odbc.c +++ b/ext/odbc/php_odbc.c @@ -1015,7 +1015,7 @@ PHP_FUNCTION(odbc_execute) if (ZSTR_LEN(tmpstr) > 2 && ZSTR_VAL(tmpstr)[0] == '\'' && - ZSTR_VAL(tmpstr)[ZSTR_LEN(tmpstr) - 1] == '\'') { + zend_string_ends_with_literal(tmpstr, "'")) { if (UNEXPECTED(zend_str_has_nul_byte(tmpstr))) { odbc_release_params(result, params); diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index cf62765d9e1d..96bf83a35527 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -1519,8 +1519,8 @@ static void zend_accel_add_key(zend_string *key, zend_accel_hash_entry *bucket) static zend_always_inline bool is_phar_file(const zend_string *filename) { - return filename && ZSTR_LEN(filename) >= sizeof(".phar") && - !memcmp(ZSTR_VAL(filename) + ZSTR_LEN(filename) - (sizeof(".phar")-1), ".phar", sizeof(".phar")-1) && + return filename && + zend_string_ends_with_literal(filename, ".phar") && !strstr(ZSTR_VAL(filename), "://"); } diff --git a/ext/opcache/ZendAccelerator.h b/ext/opcache/ZendAccelerator.h index b76e5d1d4be7..fe83800f3a06 100644 --- a/ext/opcache/ZendAccelerator.h +++ b/ext/opcache/ZendAccelerator.h @@ -198,6 +198,9 @@ typedef struct _zend_accel_globals { bool counted; /* the process uses shared memory */ bool enabled; bool locked; /* thread obtained exclusive lock */ +#ifdef ZTS + uint32_t unprotect_depth; +#endif bool accelerator_enabled; /* accelerator enabled for current request */ bool pcre_reseted; zend_accel_directives accel_directives; diff --git a/ext/opcache/jit/zend_jit_ir.c b/ext/opcache/jit/zend_jit_ir.c index 2bbd7b0e3f4d..9849bda4cd2f 100644 --- a/ext/opcache/jit/zend_jit_ir.c +++ b/ext/opcache/jit/zend_jit_ir.c @@ -8453,7 +8453,7 @@ static int zend_jit_isset_isempty_cv(zend_jit_ctx *jit, const zend_op *opline, u typedef struct _zend_closure { zend_object std; zend_function func; - zval this_ptr; + zend_object *this_ptr; zend_class_entry *called_scope; zif_handler orig_internal_handler; } zend_closure; @@ -8708,17 +8708,17 @@ static int zend_jit_push_call_frame(zend_jit_ctx *jit, const zend_op *opline, co ir_AND_U32( ir_LOAD_U32(ir_ADD_OFFSET(func_ref, offsetof(zend_closure, func.common.fn_flags))), ir_CONST_U32(ZEND_ACC_FAKE_CLOSURE)), - ir_CONST_U32(ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_DYNAMIC | ZEND_CALL_CLOSURE)); - // JIT: if (Z_TYPE(closure->this_ptr) != IS_UNDEF) { - if_cond = ir_IF(ir_LOAD_U8(ir_ADD_OFFSET(func_ref, offsetof(zend_closure, this_ptr.u1.v.type)))); + ir_CONST_U32(ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_DYNAMIC | ZEND_CALL_CLOSURE)); + + // JIT: object_or_called_scope = closure->this_ptr; + object = ir_LOAD_A(ir_ADD_OFFSET(func_ref, offsetof(zend_closure, this_ptr))); + // JIT: if (closure->this_ptr != NULL) { + if_cond = ir_IF(object); ir_IF_TRUE(if_cond); // JIT: call_info |= ZEND_CALL_HAS_THIS; call_info2 = ir_OR_U32(call_info, ir_CONST_U32(ZEND_CALL_HAS_THIS)); - // JIT: object_or_called_scope = Z_OBJ(closure->this_ptr); - object = ir_LOAD_A(ir_ADD_OFFSET(func_ref, offsetof(zend_closure, this_ptr.value.ptr))); - ir_MERGE_WITH_EMPTY_FALSE(if_cond); call_info = ir_PHI_2(IR_U32, call_info2, call_info); object_or_called_scope = ir_PHI_2(IR_ADDR, object, object_or_called_scope); diff --git a/ext/opcache/zend_shared_alloc.c b/ext/opcache/zend_shared_alloc.c index b264f98a02b7..49c7d261573a 100644 --- a/ext/opcache/zend_shared_alloc.c +++ b/ext/opcache/zend_shared_alloc.c @@ -53,6 +53,11 @@ static const char *g_shared_model; /* pointer to globals allocated in SHM and shared across processes */ ZEND_EXT_API zend_smm_shared_globals *smm_shared_globals; +#ifdef ZTS +static MUTEX_T zts_protect_lock; +static uint32_t zts_unprotected_threads; +#endif + #ifndef ZEND_WIN32 #ifdef ZTS static MUTEX_T zts_lock; @@ -184,6 +189,11 @@ int zend_shared_alloc_startup(size_t requested_size, size_t reserved_size) int res = ALLOC_FAILURE; int i; +#ifdef ZTS + zts_protect_lock = tsrm_mutex_alloc(); + zts_unprotected_threads = 0; +#endif + /* shared_free must be valid before we call zend_shared_alloc() * - make it temporarily point to a local variable */ @@ -341,6 +351,9 @@ void zend_shared_alloc_shutdown(void) tsrm_mutex_free(zts_lock); # endif #endif +#ifdef ZTS + tsrm_mutex_free(zts_protect_lock); +#endif } static size_t zend_shared_alloc_get_largest_free_block(void) @@ -628,25 +641,37 @@ const char *zend_accel_get_shared_model(void) void zend_accel_shared_protect(bool protected) { -#ifdef HAVE_MPROTECT +#if defined(HAVE_MPROTECT) || defined(ZEND_WIN32) int i; if (!smm_shared_globals) { return; } +# ifdef ZTS + /* Memory protection is process-wide, so overlapping writers must be tracked across threads. */ + tsrm_mutex_lock(zts_protect_lock); + if (protected) { + if (ZCG(unprotect_depth) && --ZCG(unprotect_depth) == 0) { + ZEND_ASSERT(zts_unprotected_threads > 0); + zts_unprotected_threads--; + } + if (zts_unprotected_threads) { + tsrm_mutex_unlock(zts_protect_lock); + return; + } + } else if (ZCG(unprotect_depth)++ == 0) { + zts_unprotected_threads++; + } +# endif + +# ifdef HAVE_MPROTECT const int mode = protected ? PROT_READ : PROT_READ|PROT_WRITE; for (i = 0; i < ZSMMG(shared_segments_count); i++) { mprotect(ZSMMG(shared_segments)[i]->p, ZSMMG(shared_segments)[i]->end, mode); } -#elif defined(ZEND_WIN32) - int i; - - if (!smm_shared_globals) { - return; - } - +# elif defined(ZEND_WIN32) const int mode = protected ? PAGE_READONLY : PAGE_READWRITE; for (i = 0; i < ZSMMG(shared_segments_count); i++) { @@ -655,6 +680,11 @@ void zend_accel_shared_protect(bool protected) zend_accel_error_noreturn(ACCEL_LOG_ERROR, "Failed to protect memory"); } } +# endif + +# ifdef ZTS + tsrm_mutex_unlock(zts_protect_lock); +# endif #endif } diff --git a/ext/pcntl/tests/async_signals_2.phpt b/ext/pcntl/tests/async_signals_2.phpt index 95a5a219768f..f94a8881ee09 100644 --- a/ext/pcntl/tests/async_signals_2.phpt +++ b/ext/pcntl/tests/async_signals_2.phpt @@ -22,9 +22,9 @@ try { array_fill(0, 360, 0) ); } catch (Exception $e) { - echo $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- -Alarm! +Exception: Alarm! diff --git a/ext/pcntl/tests/bug81577.phpt b/ext/pcntl/tests/bug81577.phpt index 7bf3b7ffea4d..557e719bd8ad 100644 --- a/ext/pcntl/tests/bug81577.phpt +++ b/ext/pcntl/tests/bug81577.phpt @@ -19,13 +19,13 @@ for ($i = 0; $i < 5; $i++) { C::$a + C::$a; posix_kill(posix_getpid(), SIGTERM) + C::$cond; } catch (Throwable $ex) { - echo get_class($ex) , " : " , $ex->getMessage() , "\n"; + echo $ex::class, ': ', $ex->getMessage(), "\n"; } } ?> --EXPECT-- -Exception : Signal -Exception : Signal -Exception : Signal -Exception : Signal -Exception : Signal +Exception: Signal +Exception: Signal +Exception: Signal +Exception: Signal +Exception: Signal diff --git a/ext/pcntl/tests/bug81577_2.phpt b/ext/pcntl/tests/bug81577_2.phpt index 2f92502df530..c77617dfb784 100644 --- a/ext/pcntl/tests/bug81577_2.phpt +++ b/ext/pcntl/tests/bug81577_2.phpt @@ -10,7 +10,7 @@ pcntl_signal(SIGTERM, function ($signo) {}); try { $a = [1, posix_kill(posix_getpid(), SIGTERM), 2]; } catch (Throwable $ex) { - echo get_class($ex) , " : " , $ex->getMessage() , "\n"; + echo $ex::class, ': ', $ex->getMessage(), "\n"; } var_dump($a); ?> diff --git a/ext/pcntl/tests/bug81577_3.phpt b/ext/pcntl/tests/bug81577_3.phpt index 1a30deaebaab..c50a04d68a47 100644 --- a/ext/pcntl/tests/bug81577_3.phpt +++ b/ext/pcntl/tests/bug81577_3.phpt @@ -12,8 +12,8 @@ pcntl_signal(SIGTERM, function ($signo) { throw new Exception("Signal"); }); try { array_merge([1], [2]) + posix_kill(posix_getpid(), SIGTERM); } catch (Throwable $ex) { - echo get_class($ex) , " : " , $ex->getMessage() , "\n"; + echo $ex::class, ': ', $ex->getMessage(), "\n"; } ?> --EXPECT-- -Exception : Signal +Exception: Signal diff --git a/ext/pcntl/tests/gh16769.phpt b/ext/pcntl/tests/gh16769.phpt index 60baee616101..5f9383882f86 100644 --- a/ext/pcntl/tests/gh16769.phpt +++ b/ext/pcntl/tests/gh16769.phpt @@ -11,8 +11,8 @@ $a[0] = &$a; try { pcntl_sigwaitinfo($a,$a); } catch(\TypeError $e) { - echo $e->getMessage(); + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } ?> --EXPECT-- -pcntl_sigwaitinfo(): Argument #1 ($signals) signals must be of type int, array given +TypeError: pcntl_sigwaitinfo(): Argument #1 ($signals) signals must be of type int, array given diff --git a/ext/pcntl/tests/pcntl_alarm_invalid_value.phpt b/ext/pcntl/tests/pcntl_alarm_invalid_value.phpt index 59e74662f6f7..cc53a3ee04f8 100644 --- a/ext/pcntl/tests/pcntl_alarm_invalid_value.phpt +++ b/ext/pcntl/tests/pcntl_alarm_invalid_value.phpt @@ -10,26 +10,26 @@ pcntl try { pcntl_alarm(-1); } catch (\ValueError $e) { - echo $e->getMessage() . \PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { pcntl_alarm(PHP_INT_MIN); } catch (\ValueError $e) { - echo $e->getMessage() . \PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { pcntl_alarm(PHP_INT_MAX); } catch (\ValueError $e) { - echo $e->getMessage() . \PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } var_dump(pcntl_alarm(0)); ?> --EXPECTF-- -pcntl_alarm(): Argument #1 ($seconds) must be between 0 and %d -pcntl_alarm(): Argument #1 ($seconds) must be between 0 and %d -pcntl_alarm(): Argument #1 ($seconds) must be between 0 and %d +ValueError: pcntl_alarm(): Argument #1 ($seconds) must be between 0 and %d +ValueError: pcntl_alarm(): Argument #1 ($seconds) must be between 0 and %d +ValueError: pcntl_alarm(): Argument #1 ($seconds) must be between 0 and %d int(0) diff --git a/ext/pcntl/tests/pcntl_exec_004.phpt b/ext/pcntl/tests/pcntl_exec_004.phpt index 270fdb755ca1..932a6a0277e7 100644 --- a/ext/pcntl/tests/pcntl_exec_004.phpt +++ b/ext/pcntl/tests/pcntl_exec_004.phpt @@ -11,15 +11,15 @@ if (!getenv("TEST_PHP_EXECUTABLE") || !is_executable(getenv("TEST_PHP_EXECUTABLE try { pcntl_exec(getenv("TEST_PHP_EXECUTABLE"), ['-n', new stdClass()]); } catch (Error $error) { - echo $error->getMessage() . "\n"; + echo $error::class, ': ', $error->getMessage(), "\n"; } try { pcntl_exec(getenv("TEST_PHP_EXECUTABLE"), ['-n'], [new stdClass()]); } catch (Error $error) { - echo $error->getMessage() . "\n"; + echo $error::class, ': ', $error->getMessage(), "\n"; } ?> --EXPECT-- -Object of class stdClass could not be converted to string -Object of class stdClass could not be converted to string +Error: Object of class stdClass could not be converted to string +Error: Object of class stdClass could not be converted to string diff --git a/ext/pcntl/tests/pcntl_getpriority_error.phpt b/ext/pcntl/tests/pcntl_getpriority_error.phpt index 2fa88a76842d..3ca9243dddfe 100644 --- a/ext/pcntl/tests/pcntl_getpriority_error.phpt +++ b/ext/pcntl/tests/pcntl_getpriority_error.phpt @@ -23,7 +23,7 @@ if (PHP_OS == "Darwin") { try { pcntl_getpriority(null, PRIO_PGRP + PRIO_USER + PRIO_PROCESS + 10); } catch (ValueError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } // Different behavior in MacOS than rest of operating systems @@ -31,6 +31,6 @@ pcntl_getpriority(-1, PRIO_PROCESS); ?> --EXPECTF-- -pcntl_getpriority(): Argument #2 ($mode) must be one of PRIO_PGRP, PRIO_USER, or PRIO_PROCESS +ValueError: pcntl_getpriority(): Argument #2 ($mode) must be one of PRIO_PGRP, PRIO_USER, or PRIO_PROCESS Warning: pcntl_getpriority(): Error %d: No process was located using the given parameters in %s diff --git a/ext/pcntl/tests/pcntl_setpriority_error.phpt b/ext/pcntl/tests/pcntl_setpriority_error.phpt index 6f0a67977a8f..1c40d747602b 100644 --- a/ext/pcntl/tests/pcntl_setpriority_error.phpt +++ b/ext/pcntl/tests/pcntl_setpriority_error.phpt @@ -23,13 +23,13 @@ if (PHP_OS == "Darwin") { try { $result = pcntl_setpriority(0, null, (PRIO_PGRP + PRIO_USER + PRIO_PROCESS + 10)); } catch (ValueError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } pcntl_setpriority(0, -123); ?> --EXPECTF-- -pcntl_setpriority(): Argument #3 ($mode) must be one of PRIO_PGRP, PRIO_USER, or PRIO_PROCESS +ValueError: pcntl_setpriority(): Argument #3 ($mode) must be one of PRIO_PGRP, PRIO_USER, or PRIO_PROCESS Warning: pcntl_setpriority(): Error 3: No process was located using the given parameters in %s diff --git a/ext/pcntl/tests/pcntl_signal.phpt b/ext/pcntl/tests/pcntl_signal.phpt index 2e65139e3937..f4ae1ef07e10 100644 --- a/ext/pcntl/tests/pcntl_signal.phpt +++ b/ext/pcntl/tests/pcntl_signal.phpt @@ -22,19 +22,19 @@ var_dump(pcntl_signal(SIGALRM, SIG_IGN)); try { pcntl_signal(-1, -1); } catch (ValueError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } try { pcntl_signal(-1, function(){}); } catch (ValueError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } try { pcntl_signal(SIGALRM, "not callable"); } catch (TypeError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } /* test freeing queue in RSHUTDOWN */ @@ -45,7 +45,7 @@ echo "ok\n"; signal dispatched got signal from %r\d+|nobody%r bool(true) -pcntl_signal(): Argument #1 ($signal) must be greater than or equal to 1 -pcntl_signal(): Argument #1 ($signal) must be greater than or equal to 1 -pcntl_signal(): Argument #2 ($handler) must be of type callable|int, string given +ValueError: pcntl_signal(): Argument #1 ($signal) must be greater than or equal to 1 +ValueError: pcntl_signal(): Argument #1 ($signal) must be greater than or equal to 1 +TypeError: pcntl_signal(): Argument #2 ($handler) must be of type callable|int, string given ok diff --git a/ext/pcntl/tests/pcntl_signal_001.phpt b/ext/pcntl/tests/pcntl_signal_001.phpt index 2f4f385553a2..0b9a0f1d3577 100644 --- a/ext/pcntl/tests/pcntl_signal_001.phpt +++ b/ext/pcntl/tests/pcntl_signal_001.phpt @@ -9,8 +9,8 @@ try { echo "signaled\n"; }); } catch (Error $e) { - echo $e->getMessage(); + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } ?> --EXPECTF-- -pcntl_signal(): Argument #1 ($signal) must be less than %d +ValueError: pcntl_signal(): Argument #1 ($signal) must be less than %d diff --git a/ext/pcntl/tests/pcntl_signal_002.phpt b/ext/pcntl/tests/pcntl_signal_002.phpt index 1d4e29d94a75..f98392205e21 100644 --- a/ext/pcntl/tests/pcntl_signal_002.phpt +++ b/ext/pcntl/tests/pcntl_signal_002.phpt @@ -8,9 +8,9 @@ pcntl try { pcntl_signal(SIGTERM, -1); } catch (Error $error) { - echo $error->getMessage(); + echo $error::class, ': ', $error->getMessage(), PHP_EOL; } ?> --EXPECT-- -pcntl_signal(): Argument #2 ($handler) must be either SIG_DFL or SIG_IGN when an integer value is given +ValueError: pcntl_signal(): Argument #2 ($handler) must be either SIG_DFL or SIG_IGN when an integer value is given diff --git a/ext/pcntl/tests/pcntl_signal_dispatch_exception.phpt b/ext/pcntl/tests/pcntl_signal_dispatch_exception.phpt index 06c4f827c6ef..1558b7556d21 100644 --- a/ext/pcntl/tests/pcntl_signal_dispatch_exception.phpt +++ b/ext/pcntl/tests/pcntl_signal_dispatch_exception.phpt @@ -23,12 +23,12 @@ posix_kill(posix_getpid(), SIGUSR2); try { pcntl_signal_dispatch(); } catch (\Exception $e) { - echo $e->getMessage() . "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } echo "Handlers called: " . implode(', ', $called) . "\n"; ?> --EXPECT-- -Exception in signal handler +Exception: Exception in signal handler Handlers called: SIGUSR1 diff --git a/ext/pcntl/tests/pcntl_signal_functions_invalid_signals.phpt b/ext/pcntl/tests/pcntl_signal_functions_invalid_signals.phpt index e61b17bf3fbd..bd7e22e6634a 100644 --- a/ext/pcntl/tests/pcntl_signal_functions_invalid_signals.phpt +++ b/ext/pcntl/tests/pcntl_signal_functions_invalid_signals.phpt @@ -16,65 +16,65 @@ max_execution_time=0 try { pcntl_sigprocmask(SIG_BLOCK, ["not_a_signal"]); } catch (TypeError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { pcntl_sigprocmask(SIG_BLOCK, [0]); } catch (ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { pcntl_sigprocmask(SIG_BLOCK, []); } catch (ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { pcntl_sigwaitinfo(["not_a_signal"]); } catch (TypeError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { pcntl_sigwaitinfo([0]); } catch (ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { pcntl_sigwaitinfo([]); } catch (ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { pcntl_sigtimedwait(["not_a_signal"], $info, 1); } catch (TypeError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { pcntl_sigtimedwait([0], $info, 1); } catch (ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { pcntl_sigtimedwait([], $info, 1); } catch (ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } ?> --EXPECTF-- -pcntl_sigprocmask(): Argument #2 ($signals) signals must be of type int, string given -pcntl_sigprocmask(): Argument #2 ($signals) signals must be between 1 and %d -pcntl_sigprocmask(): Argument #2 ($signals) must not be empty -pcntl_sigwaitinfo(): Argument #1 ($signals) signals must be of type int, string given -pcntl_sigwaitinfo(): Argument #1 ($signals) signals must be between 1 and %d -pcntl_sigwaitinfo(): Argument #1 ($signals) must not be empty -pcntl_sigtimedwait(): Argument #1 ($signals) signals must be of type int, string given -pcntl_sigtimedwait(): Argument #1 ($signals) signals must be between 1 and %d -pcntl_sigtimedwait(): Argument #1 ($signals) must not be empty +TypeError: pcntl_sigprocmask(): Argument #2 ($signals) signals must be of type int, string given +ValueError: pcntl_sigprocmask(): Argument #2 ($signals) signals must be between 1 and %d +ValueError: pcntl_sigprocmask(): Argument #2 ($signals) must not be empty +TypeError: pcntl_sigwaitinfo(): Argument #1 ($signals) signals must be of type int, string given +ValueError: pcntl_sigwaitinfo(): Argument #1 ($signals) signals must be between 1 and %d +ValueError: pcntl_sigwaitinfo(): Argument #1 ($signals) must not be empty +TypeError: pcntl_sigtimedwait(): Argument #1 ($signals) signals must be of type int, string given +ValueError: pcntl_sigtimedwait(): Argument #1 ($signals) signals must be between 1 and %d +ValueError: pcntl_sigtimedwait(): Argument #1 ($signals) must not be empty diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index 3a1b4a04cafb..9f0ca2c1a5e6 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -3427,13 +3427,13 @@ static zend_result pgsql_copy_from_query(PGconn *pgsql, PGresult *pgsql_result, } int result; - if (ZSTR_LEN(tmp) > 0 && ZSTR_VAL(tmp)[ZSTR_LEN(tmp) - 1] != '\n') { + if (ZSTR_LEN(tmp) == 0 || zend_string_ends_with_literal(tmp, "\n")) { + result = PQputCopyData(pgsql, ZSTR_VAL(tmp), ZSTR_LEN(tmp)); + } else { char *zquery = zend_cstr_append_char( ZSTR_VAL(tmp), ZSTR_LEN(tmp), '\n'); result = PQputCopyData(pgsql, zquery, ZSTR_LEN(tmp) + 1); efree(zquery); - } else { - result = PQputCopyData(pgsql, ZSTR_VAL(tmp), ZSTR_LEN(tmp)); } zend_tmp_string_release(tmp_tmp); diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index 8a330a954b89..2fc17e7b9cea 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -4251,7 +4251,7 @@ ZEND_ATTRIBUTE_NONNULL_ARGS(1, 3, 5) static int extract_helper(const phar_archiv if (FAILURE == phar_extract_file(overwrite, entry, path_to, error)) return -1; extracted++; } ZEND_HASH_FOREACH_END(); - } else if (ZSTR_LEN(search) > 0 && '/' == ZSTR_VAL(search)[ZSTR_LEN(search) - 1]) { + } else if (zend_string_ends_with_literal(search, "/")) { /* ends in "/" -- extract all entries having that prefix */ ZEND_HASH_MAP_FOREACH_PTR(&archive->manifest, entry) { if (!zend_string_starts_with(entry->filename, search)) continue; diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 07a671739f32..1accd39e2578 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -1772,9 +1772,9 @@ ZEND_METHOD(ReflectionFunctionAbstract, getClosureThis) GET_REFLECTION_OBJECT(); if (!Z_ISUNDEF(intern->obj)) { - zval *closure_this = zend_get_closure_this_ptr(&intern->obj); - if (!Z_ISUNDEF_P(closure_this)) { - RETURN_OBJ_COPY(Z_OBJ_P(closure_this)); + zend_object *closure_this = zend_get_closure_this_ptr(&intern->obj); + if (closure_this) { + RETURN_OBJ_COPY(closure_this); } } } @@ -3334,7 +3334,7 @@ ZEND_METHOD(ReflectionMethod, getClosure) { RETURN_OBJ_COPY(Z_OBJ_P(obj)); } - zend_create_fake_closure(return_value, mptr, mptr->common.scope, Z_OBJCE_P(obj), obj); + zend_create_fake_closure(return_value, mptr, mptr->common.scope, Z_OBJCE_P(obj), Z_OBJ_P(obj)); } /* }}} */ diff --git a/ext/session/session.c b/ext/session/session.c index cb951c6d60eb..452a3446fc14 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -876,7 +876,7 @@ static PHP_INI_MH(OnUpdateRfc1867Freq) return FAILURE; } - if (ZSTR_LEN(new_value) > 0 && ZSTR_VAL(new_value)[ZSTR_LEN(new_value) - 1] == '%') { + if (zend_string_ends_with_literal(new_value, "%")) { if (new_freq > 100) { php_error_docref(NULL, E_WARNING, "session.upload_progress.freq must be less than or equal to 100%%"); return FAILURE; diff --git a/ext/soap/php_http.c b/ext/soap/php_http.c index b49acd947b39..5df9506102af 100644 --- a/ext/soap/php_http.c +++ b/ext/soap/php_http.c @@ -341,13 +341,9 @@ static php_stream* http_connect(zval* this_ptr, php_uri *uri, bool use_ssl, php_ static bool in_domain(const zend_string *host, const zend_string *domain) { if (ZSTR_VAL(domain)[0] == '.') { - if (ZSTR_LEN(host) > ZSTR_LEN(domain)) { - return zend_string_equals_cstr(domain, ZSTR_VAL(host) + ZSTR_LEN(host) - ZSTR_LEN(domain), ZSTR_LEN(domain)); - } else { - return false; - } + return zend_string_ends_with(host, domain); } else { - return zend_string_equals(host,domain); + return zend_string_equals(host, domain); } } diff --git a/ext/soap/tests/bugs/bug31755.phpt b/ext/soap/tests/bugs/bug31755.phpt index c4b2c622b6af..2cd623888b55 100644 --- a/ext/soap/tests/bugs/bug31755.phpt +++ b/ext/soap/tests/bugs/bug31755.phpt @@ -17,7 +17,7 @@ $client = new MySoapClient(null, array( try { new SOAPHeader('', 'foo', 'bar'); } catch (ValueError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } $header = new SOAPHeader('namespace', 'foo', 'bar'); @@ -26,6 +26,6 @@ $response= $client->__soapCall('function', array(), null, $header); print $client->__getLastRequest(); ?> --EXPECT-- -SoapHeader::__construct(): Argument #1 ($namespace) must not be empty +ValueError: SoapHeader::__construct(): Argument #1 ($namespace) must not be empty bar diff --git a/ext/soap/tests/bugs/bug42151.phpt b/ext/soap/tests/bugs/bug42151.phpt index 2f9c1830ad39..ef8f744b1374 100644 --- a/ext/soap/tests/bugs/bug42151.phpt +++ b/ext/soap/tests/bugs/bug42151.phpt @@ -21,12 +21,12 @@ try { $bar = new bar(); $foo = new foo(); } catch (Exception $e){ - echo $e->getMessage() . "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } echo "ok\n"; ?> --EXPECTF-- -SOAP-ERROR: Parsing WSDL: Couldn't load from 'httpx://' : failed to load %s +SoapFault: SOAP-ERROR: Parsing WSDL: Couldn't load from 'httpx://' : failed to load %s ok I don't get executed either. diff --git a/ext/soap/tests/bugs/bug42692.phpt b/ext/soap/tests/bugs/bug42692.phpt index fe4840d9268d..78126325ad5c 100644 --- a/ext/soap/tests/bugs/bug42692.phpt +++ b/ext/soap/tests/bugs/bug42692.phpt @@ -33,7 +33,7 @@ try { $result = $client->checkAuth(1,"two"); echo "Auth for 1 is $result\n"; } catch (Exception $e) { - echo $e->getMessage(); + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } ?> --EXPECT-- diff --git a/ext/soap/tests/bugs/bug55639.phpt b/ext/soap/tests/bugs/bug55639.phpt index 16d7f7a37719..834389361982 100644 --- a/ext/soap/tests/bugs/bug55639.phpt +++ b/ext/soap/tests/bugs/bug55639.phpt @@ -44,7 +44,7 @@ $client = new soapclient(NULL, [ try { $client->__soapCall("foo", []); } catch (Throwable $e) { - echo $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } $headers = $client->__getLastRequestHeaders(); @@ -52,7 +52,7 @@ var_dump($headers); ?> --EXPECTF-- -Unauthorized +SoapFault: Unauthorized string(%d) "POST / HTTP/1.1 Host: %s Connection: Keep-Alive diff --git a/ext/soap/tests/bugs/bug71610.phpt b/ext/soap/tests/bugs/bug71610.phpt index f7f674fa0593..34709c5b0693 100644 --- a/ext/soap/tests/bugs/bug71610.phpt +++ b/ext/soap/tests/bugs/bug71610.phpt @@ -21,8 +21,8 @@ $exploit = unserialize($ser); try { $exploit->blahblah(); } catch(SoapFault $e) { - echo $e->getMessage()."\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- -looks like we got no XML document +SoapFault: looks like we got no XML document diff --git a/ext/soap/tests/bugs/bug73037.phpt b/ext/soap/tests/bugs/bug73037.phpt index 7a5b99776772..6d94fca04e0f 100644 --- a/ext/soap/tests/bugs/bug73037.phpt +++ b/ext/soap/tests/bugs/bug73037.phpt @@ -175,4 +175,3 @@ Iteration 6 Function 'CATALOG' doesn't exist Function 'CATALOG' doesn't exist - diff --git a/ext/soap/tests/bugs/bug80672.phpt b/ext/soap/tests/bugs/bug80672.phpt index 2abc40e39134..d5f54ef6b804 100644 --- a/ext/soap/tests/bugs/bug80672.phpt +++ b/ext/soap/tests/bugs/bug80672.phpt @@ -8,8 +8,8 @@ try { $client = new SoapClient(__DIR__ . "/bug80672.xml"); $query = $soap->query(array('sXML' => 'something')); } catch(SoapFault $e) { - print $e->getMessage(); + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } ?> --EXPECT-- -SOAP-ERROR: Parsing WSDL: Unexpected WSDL element <> +SoapFault: SOAP-ERROR: Parsing WSDL: Unexpected WSDL element <> diff --git a/ext/soap/tests/bugs/gh16237.phpt b/ext/soap/tests/bugs/gh16237.phpt index 468f2794399e..c86e9c14039d 100644 --- a/ext/soap/tests/bugs/gh16237.phpt +++ b/ext/soap/tests/bugs/gh16237.phpt @@ -9,9 +9,9 @@ $server = new SoapServer(null, ['uri'=>"http://testuri.org"]); try { clone $server; } catch (Error $e) { - echo $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- -Trying to clone an uncloneable object of class SoapServer +Error: Trying to clone an uncloneable object of class SoapServer diff --git a/ext/soap/tests/bugs/gh16256.phpt b/ext/soap/tests/bugs/gh16256.phpt index a6d5f3fbbf3c..cefc05c4dd01 100644 --- a/ext/soap/tests/bugs/gh16256.phpt +++ b/ext/soap/tests/bugs/gh16256.phpt @@ -11,14 +11,14 @@ $wsdl = __DIR__."/ext/soap/tests/bug41004.wsdl"; try { new SoapClient($wsdl, ["classmap" => $classmap]); } catch (Throwable $e) { - echo $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } try { new SoapServer($wsdl, ["classmap" => $classmap]); } catch (Throwable $e) { - echo $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- -SoapClient::__construct(): Argument #2 ($options) "classmap" option must be an associative array -SoapServer::__construct(): Argument #2 ($options) "classmap" option must be an associative array +ValueError: SoapClient::__construct(): Argument #2 ($options) "classmap" option must be an associative array +ValueError: SoapServer::__construct(): Argument #2 ($options) "classmap" option must be an associative array diff --git a/ext/soap/tests/bugs/gh16429.phpt b/ext/soap/tests/bugs/gh16429.phpt index 24d517f96b96..b7073a05b23d 100644 --- a/ext/soap/tests/bugs/gh16429.phpt +++ b/ext/soap/tests/bugs/gh16429.phpt @@ -14,9 +14,9 @@ $client = new SoapClient(__DIR__."/../interop/Round2/GroupB/round2_groupB.wsdl", try { $client->echo2DStringArray($fusion); } catch (Exception $e) { - echo $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- string(10) "xxxxxxxxxx" -Cannot traverse an already closed generator +Exception: Cannot traverse an already closed generator diff --git a/ext/soap/tests/bugs/gh22167.phpt b/ext/soap/tests/bugs/gh22167.phpt index f24bfb0eac32..9a6518d2ad73 100644 --- a/ext/soap/tests/bugs/gh22167.phpt +++ b/ext/soap/tests/bugs/gh22167.phpt @@ -98,31 +98,31 @@ foreach ($cases as $name => $schema) { new SoapClient($file, ["cache_wsdl" => WSDL_CACHE_NONE]); echo "$name: parsed\n"; } catch (SoapFault $e) { - echo "$name: {$e->getMessage()}\n"; + echo "$name: ", $e::class, ': ', $e->getMessage(), "\n"; } finally { unlink($file); } } ?> --EXPECT-- -minOccurs: SOAP-ERROR: Parsing Schema: minOccurs value is out of range -maxOccurs: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range -negative minOccurs: SOAP-ERROR: Parsing Schema: minOccurs value is out of range -negative maxOccurs: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range -minExclusive: SOAP-ERROR: Parsing Schema: minExclusive value is out of range -minInclusive: SOAP-ERROR: Parsing Schema: minInclusive value is out of range -maxExclusive: SOAP-ERROR: Parsing Schema: maxExclusive value is out of range -maxInclusive: SOAP-ERROR: Parsing Schema: maxInclusive value is out of range -totalDigits: SOAP-ERROR: Parsing Schema: totalDigits value is out of range -fractionDigits: SOAP-ERROR: Parsing Schema: fractionDigits value is out of range -length: SOAP-ERROR: Parsing Schema: length value is out of range -minLength: SOAP-ERROR: Parsing Schema: minLength value is out of range -maxLength: SOAP-ERROR: Parsing Schema: maxLength value is out of range -leading whitespace numeric-string: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range -leading plus numeric-string: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range -leading zero numeric-string: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range -leading numeric-string with trailing data: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range -negative out-of-range numeric-string: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range -decimal numeric-string: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range -exponent numeric-string: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range +minOccurs: SoapFault: SOAP-ERROR: Parsing Schema: minOccurs value is out of range +maxOccurs: SoapFault: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range +negative minOccurs: SoapFault: SOAP-ERROR: Parsing Schema: minOccurs value is out of range +negative maxOccurs: SoapFault: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range +minExclusive: SoapFault: SOAP-ERROR: Parsing Schema: minExclusive value is out of range +minInclusive: SoapFault: SOAP-ERROR: Parsing Schema: minInclusive value is out of range +maxExclusive: SoapFault: SOAP-ERROR: Parsing Schema: maxExclusive value is out of range +maxInclusive: SoapFault: SOAP-ERROR: Parsing Schema: maxInclusive value is out of range +totalDigits: SoapFault: SOAP-ERROR: Parsing Schema: totalDigits value is out of range +fractionDigits: SoapFault: SOAP-ERROR: Parsing Schema: fractionDigits value is out of range +length: SoapFault: SOAP-ERROR: Parsing Schema: length value is out of range +minLength: SoapFault: SOAP-ERROR: Parsing Schema: minLength value is out of range +maxLength: SoapFault: SOAP-ERROR: Parsing Schema: maxLength value is out of range +leading whitespace numeric-string: SoapFault: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range +leading plus numeric-string: SoapFault: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range +leading zero numeric-string: SoapFault: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range +leading numeric-string with trailing data: SoapFault: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range +negative out-of-range numeric-string: SoapFault: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range +decimal numeric-string: SoapFault: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range +exponent numeric-string: SoapFault: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range fractional numeric-string within int range: parsed diff --git a/ext/soap/tests/bugs/protocol_relative_redirect.phpt b/ext/soap/tests/bugs/protocol_relative_redirect.phpt index e8f30ca66872..e9c30f0ab290 100644 --- a/ext/soap/tests/bugs/protocol_relative_redirect.phpt +++ b/ext/soap/tests/bugs/protocol_relative_redirect.phpt @@ -42,7 +42,7 @@ try { $client->__soapCall("foo", []); echo "redirect followed\n"; } catch (SoapFault $e) { - echo "SoapFault: " . $e->getMessage() . "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- diff --git a/ext/soap/tests/bugs/relative_redirect.phpt b/ext/soap/tests/bugs/relative_redirect.phpt index 774e7cbd98d7..ebdcd97e5d49 100644 --- a/ext/soap/tests/bugs/relative_redirect.phpt +++ b/ext/soap/tests/bugs/relative_redirect.phpt @@ -42,7 +42,7 @@ try { $client->__soapCall("foo", []); echo "redirect followed\n"; } catch (SoapFault $e) { - echo "SoapFault: " . $e->getMessage() . "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- diff --git a/ext/soap/tests/bugs/relative_redirect_path.phpt b/ext/soap/tests/bugs/relative_redirect_path.phpt index 09d4c857cc92..2e18c12b926f 100644 --- a/ext/soap/tests/bugs/relative_redirect_path.phpt +++ b/ext/soap/tests/bugs/relative_redirect_path.phpt @@ -42,7 +42,7 @@ try { $client->__soapCall("foo", []); echo "redirect followed\n"; } catch (SoapFault $e) { - echo "SoapFault: " . $e->getMessage() . "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- diff --git a/ext/soap/tests/fault_warning.phpt b/ext/soap/tests/fault_warning.phpt index 2a9d99fb5dbd..d8c2921a8ef8 100644 --- a/ext/soap/tests/fault_warning.phpt +++ b/ext/soap/tests/fault_warning.phpt @@ -8,13 +8,13 @@ soap try { new SoapFault("", "message"); // Can't be an empty string } catch (ValueError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } try { new SoapFault(new stdClass(), "message"); // Can't be a non-string (except for null) } catch (TypeError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } $fault = new SoapFault("Sender", "message"); @@ -25,13 +25,13 @@ echo get_class($fault) . "\n"; try { new SoapFault(["more"], "message"); // two elements in array required } catch (ValueError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } try { new SoapFault(["m", "more", "superfluous"], "message"); // two required } catch (ValueError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } $fault = new SoapFault(["more-ns", "Sender"], "message"); // two given @@ -39,10 +39,10 @@ echo get_class($fault); ?> --EXPECT-- -SoapFault::__construct(): Argument #1 ($code) is not a valid fault code -SoapFault::__construct(): Argument #1 ($code) must be of type array|string|null, stdClass given +ValueError: SoapFault::__construct(): Argument #1 ($code) is not a valid fault code +TypeError: SoapFault::__construct(): Argument #1 ($code) must be of type array|string|null, stdClass given SoapFault SoapFault -SoapFault::__construct(): Argument #1 ($code) is not a valid fault code -SoapFault::__construct(): Argument #1 ($code) is not a valid fault code +ValueError: SoapFault::__construct(): Argument #1 ($code) is not a valid fault code +ValueError: SoapFault::__construct(): Argument #1 ($code) is not a valid fault code SoapFault diff --git a/ext/soap/tests/gh15711.phpt b/ext/soap/tests/gh15711.phpt index 17ff051698fd..d3c04d319ab1 100644 --- a/ext/soap/tests/gh15711.phpt +++ b/ext/soap/tests/gh15711.phpt @@ -64,7 +64,7 @@ $book->short = NonBackedEnum::First; try { $client->dotest($book); } catch (ValueError $e) { - echo "ValueError: ", $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } echo "--- Test with mismatched enum backing type ---\n"; @@ -74,7 +74,7 @@ $book->short = StringBackedEnum::First; try { $client->dotest($book); } catch (ValueError $e) { - echo "ValueError: ", $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> diff --git a/ext/soap/tests/gh16318.phpt b/ext/soap/tests/gh16318.phpt index 0c38b6fc8de3..ce0490d95927 100644 --- a/ext/soap/tests/gh16318.phpt +++ b/ext/soap/tests/gh16318.phpt @@ -26,11 +26,11 @@ foreach ([$test1, $test2] as $test) { try { $client->__soapCall("echoStructArray", array($test), array("soapaction"=>"http://soapinterop.org/","uri"=>"http://soapinterop.org/")); } catch (ValueError $e) { - echo $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } } ?> --EXPECT-- -Recursive array cannot be encoded -Recursive array cannot be encoded +ValueError: Recursive array cannot be encoded +ValueError: Recursive array cannot be encoded diff --git a/ext/xml/tests/bug78563.phpt b/ext/xml/tests/bug78563.phpt index dc7d5fe02dc2..94dec81e792c 100644 --- a/ext/xml/tests/bug78563.phpt +++ b/ext/xml/tests/bug78563.phpt @@ -9,7 +9,7 @@ try { $parser = xml_parser_create(); clone $parser; } catch (Throwable $e) { - echo $e::class, ": ", $e->getMessage(), PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } ?> diff --git a/ext/xml/tests/gh15868.phpt b/ext/xml/tests/gh15868.phpt index 17ed80558d78..0e3b866574f6 100644 --- a/ext/xml/tests/gh15868.phpt +++ b/ext/xml/tests/gh15868.phpt @@ -14,7 +14,7 @@ xml_set_element_handler($parser, try { xml_parse_into_struct($parser, "", $values, $tags); } catch (Error $e) { - echo $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } $parser = xml_parser_create(); @@ -27,7 +27,7 @@ xml_set_element_handler($parser, try { xml_parse_into_struct($parser, "", $values, $tags); } catch (Error $e) { - echo $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } $parser = xml_parser_create(); @@ -37,10 +37,10 @@ xml_set_character_data_handler($parser, function() { try { xml_parse_into_struct($parser, "", $values, $tags); } catch (Error $e) { - echo $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- -stop 1 -stop 2 -stop 3 +Error: stop 1 +Error: stop 2 +Error: stop 3 diff --git a/ext/xml/tests/xml_parser_get_option_variation4.phpt b/ext/xml/tests/xml_parser_get_option_variation4.phpt index f6d858a7e9c0..4afc09c41219 100644 --- a/ext/xml/tests/xml_parser_get_option_variation4.phpt +++ b/ext/xml/tests/xml_parser_get_option_variation4.phpt @@ -10,9 +10,9 @@ $xmlParser = xml_parser_create(); try { xml_parser_get_option ($xmlParser, 42); } catch (ValueError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } ?> --EXPECT-- -xml_parser_get_option(): Argument #2 ($option) must be a XML_OPTION_* constant +ValueError: xml_parser_get_option(): Argument #2 ($option) must be a XML_OPTION_* constant diff --git a/ext/xml/tests/xml_parser_set_option_errors.phpt b/ext/xml/tests/xml_parser_set_option_errors.phpt index fbb733423d77..9e722162c3bc 100644 --- a/ext/xml/tests/xml_parser_set_option_errors.phpt +++ b/ext/xml/tests/xml_parser_set_option_errors.phpt @@ -11,24 +11,24 @@ echo "Case folding\n"; try { xml_parser_set_option($xmlParser, XML_OPTION_CASE_FOLDING, []); } catch (ValueError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } try { xml_parser_set_option($xmlParser, XML_OPTION_CASE_FOLDING, new stdClass()); } catch (TypeError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } echo "Skip Whitespace\n"; try { xml_parser_set_option($xmlParser, XML_OPTION_SKIP_WHITE, []); } catch (ValueError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } try { xml_parser_set_option($xmlParser, XML_OPTION_SKIP_WHITE, new stdClass()); } catch (TypeError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } echo "Tag Start\n"; @@ -42,17 +42,17 @@ echo "Encodings\n"; try { xml_parser_set_option($xmlParser, XML_OPTION_TARGET_ENCODING, 'Invalid Encoding'); } catch (ValueError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } try { xml_parser_set_option($xmlParser, XML_OPTION_TARGET_ENCODING, []); } catch (ValueError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } try { xml_parser_set_option($xmlParser, XML_OPTION_TARGET_ENCODING, new stdClass()); } catch (Error $exception) { - echo $exception::class, ': ', $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } ?> @@ -77,12 +77,12 @@ Warning: xml_parser_set_option(): Argument #3 ($value) must be of type string|in Warning: Object of class stdClass could not be converted to int in %s on line %d Encodings -xml_parser_set_option(): Argument #3 ($value) is not a supported target encoding +ValueError: xml_parser_set_option(): Argument #3 ($value) is not a supported target encoding Warning: xml_parser_set_option(): Argument #3 ($value) must be of type string|int|bool, array given in %s on line %d Warning: Array to string conversion in %s on line %d -xml_parser_set_option(): Argument #3 ($value) is not a supported target encoding +ValueError: xml_parser_set_option(): Argument #3 ($value) is not a supported target encoding Warning: xml_parser_set_option(): Argument #3 ($value) must be of type string|int|bool, stdClass given in %s on line %d Error: Object of class stdClass could not be converted to string diff --git a/ext/xml/tests/xml_parser_set_option_nonexistent_option.phpt b/ext/xml/tests/xml_parser_set_option_nonexistent_option.phpt index d19dc9e69d5c..3bed7aefd7f6 100644 --- a/ext/xml/tests/xml_parser_set_option_nonexistent_option.phpt +++ b/ext/xml/tests/xml_parser_set_option_nonexistent_option.phpt @@ -10,9 +10,9 @@ $xmlParser = xml_parser_create(); try { xml_parser_set_option($xmlParser, 42, 1); } catch (ValueError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } ?> --EXPECT-- -xml_parser_set_option(): Argument #2 ($option) must be a XML_OPTION_* constant +ValueError: xml_parser_set_option(): Argument #2 ($option) must be a XML_OPTION_* constant