diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c index 8c0a04729deb..bd774c776574 100644 --- a/ext/ldap/ldap.c +++ b/ext/ldap/ldap.c @@ -2694,7 +2694,7 @@ PHP_FUNCTION(ldap_modify_batch) ZVAL_DEREF(modtype_zv); if (UNEXPECTED(Z_TYPE_P(modtype_zv) != IS_LONG)) { - zend_argument_type_error(3, "the value for option \"" LDAP_MODIFY_BATCH_MODTYPE "\" must be of type int, %s given", zend_zval_value_name(attrib)); + zend_argument_type_error(3, "the value for option \"" LDAP_MODIFY_BATCH_MODTYPE "\" must be of type int, %s given", zend_zval_value_name(modtype_zv)); RETURN_THROWS(); } zend_long modtype = Z_LVAL_P(modtype_zv); @@ -2730,7 +2730,7 @@ PHP_FUNCTION(ldap_modify_batch) ZVAL_DEREF(modification_values_zv); if (Z_TYPE_P(modification_values_zv) != IS_ARRAY) { - zend_argument_type_error(3, "the value for option \"" LDAP_MODIFY_BATCH_VALUES "\" must be of type array, %s given", zend_zval_value_name(attrib)); + zend_argument_type_error(3, "the value for option \"" LDAP_MODIFY_BATCH_VALUES "\" must be of type array, %s given", zend_zval_value_name(modification_values_zv)); RETURN_THROWS(); } diff --git a/ext/ldap/tests/ldap_modify_batch_programming_error.phpt b/ext/ldap/tests/ldap_modify_batch_programming_error.phpt index b123f437aa3f..b180d15d13b8 100644 --- a/ext/ldap/tests/ldap_modify_batch_programming_error.phpt +++ b/ext/ldap/tests/ldap_modify_batch_programming_error.phpt @@ -251,7 +251,7 @@ ValueError: ldap_modify_batch(): Argument #3 ($modifications_info) a modificatio ValueError: ldap_modify_batch(): Argument #3 ($modifications_info) a modification entry must only contain the keys "attrib", "modtype", and "values" TypeError: ldap_modify_batch(): Argument #3 ($modifications_info) the value for option "attrib" must be of type string, int given ValueError: ldap_modify_batch(): Argument #3 ($modifications_info) the value for option "attrib" must not contain null bytes -TypeError: ldap_modify_batch(): Argument #3 ($modifications_info) the value for option "modtype" must be of type int, string given +TypeError: ldap_modify_batch(): Argument #3 ($modifications_info) the value for option "modtype" must be of type int, stdClass given ValueError: ldap_modify_batch(): Argument #3 ($modifications_info) the value for option "modtype" must be LDAP_MODIFY_BATCH_ADD, LDAP_MODIFY_BATCH_REMOVE, LDAP_MODIFY_BATCH_REPLACE, or LDAP_MODIFY_BATCH_REMOVE_ALL ValueError: ldap_modify_batch(): Argument #3 ($modifications_info) a modification entry must not contain the "values" option when option "modtype" is LDAP_MODIFY_BATCH_REMOVE_ALL ValueError: ldap_modify_batch(): Argument #3 ($modifications_info) a modification entry must contain the "values" option when the "modtype" option is not LDAP_MODIFY_BATCH_REMOVE_ALL diff --git a/ext/ldap/tests/ldap_modify_batch_type_error_value.phpt b/ext/ldap/tests/ldap_modify_batch_type_error_value.phpt new file mode 100644 index 000000000000..1db6b014e7b7 --- /dev/null +++ b/ext/ldap/tests/ldap_modify_batch_type_error_value.phpt @@ -0,0 +1,25 @@ +--TEST-- +ldap_modify_batch(): the type errors name the type of the rejected value +--EXTENSIONS-- +ldap +--FILE-- + "a", "modtype" => [], "values" => ["v"]]], + [["attrib" => "a", "modtype" => 1.5, "values" => ["v"]]], + [["attrib" => "a", "modtype" => LDAP_MODIFY_BATCH_ADD, "values" => "v"]], + [["attrib" => "a", "modtype" => LDAP_MODIFY_BATCH_ADD, "values" => 5]], +] as $mods) { + try { + ldap_modify_batch($l, "cn=x", $mods); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; + } +} +?> +--EXPECT-- +TypeError: ldap_modify_batch(): Argument #3 ($modifications_info) the value for option "modtype" must be of type int, array given +TypeError: ldap_modify_batch(): Argument #3 ($modifications_info) the value for option "modtype" must be of type int, float given +TypeError: ldap_modify_batch(): Argument #3 ($modifications_info) the value for option "values" must be of type array, null given +TypeError: ldap_modify_batch(): Argument #3 ($modifications_info) the value for option "values" must be of type array, int given