ext/ldap: Promote warning to ValueError if array is not a dict

This commit is contained in:
Gina Peter Banyard 2024-10-01 00:20:39 +01:00
parent 127968b1e4
commit d34d015078
3 changed files with 4 additions and 7 deletions

View file

@ -2235,7 +2235,7 @@ static void php_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper, int ext)
unsigned int attribute_index = 0; unsigned int attribute_index = 0;
ZEND_HASH_FOREACH_STR_KEY_VAL(attributes_ht, attribute, attribute_values) { ZEND_HASH_FOREACH_STR_KEY_VAL(attributes_ht, attribute, attribute_values) {
if (attribute == NULL) { if (attribute == NULL) {
php_error_docref(NULL, E_WARNING, "Unknown attribute in the data"); zend_argument_value_error(3, "must be an associative array of attribute => values");
RETVAL_FALSE; RETVAL_FALSE;
goto cleanup; goto cleanup;
} }

View file

@ -25,6 +25,5 @@ try {
} }
?> ?>
--EXPECTF-- --EXPECT--
Warning: ldap_add(): Unknown attribute in the data in %s on line %d ValueError: ldap_add(): Argument #3 ($entry) must be an associative array of attribute => values
bool(false)

View file

@ -133,9 +133,7 @@ try {
?> ?>
--EXPECTF-- --EXPECTF--
ValueError: ldap_add(): Argument #3 ($entry) must not be empty ValueError: ldap_add(): Argument #3 ($entry) must not be empty
ValueError: ldap_add(): Argument #3 ($entry) must be an associative array of attribute => values
Warning: ldap_add(): Unknown attribute in the data in %s on line %d
bool(false)
Warning: ldap_add(): Add: Can't contact LDAP server in %s on line %d Warning: ldap_add(): Add: Can't contact LDAP server in %s on line %d
bool(false) bool(false)