ext/ldap: Print correct type

This commit is contained in:
Gina Peter Banyard 2024-09-28 17:42:22 +01:00
parent 415d93eda2
commit d87711b9f4
3 changed files with 26 additions and 5 deletions

View file

@ -1650,13 +1650,13 @@ cleanup_parallel:
} }
if (!base_dn_str) { if (!base_dn_str) {
zend_argument_type_error(2, "must be of type string when argument #1 ($ldap) is an LDAP instance"); zend_argument_type_error(2, "must be of type string when argument #1 ($ldap) is an LDAP\\Connection instance");
ret = 0; ret = 0;
goto cleanup; goto cleanup;
} }
if (!filter_str) { if (!filter_str) {
zend_argument_type_error(3, "must be of type string when argument #1 ($ldap) is an LDAP instance"); zend_argument_type_error(3, "must be of type string when argument #1 ($ldap) is an LDAP\\Connection instance");
ret = 0; ret = 0;
goto cleanup; goto cleanup;
} }
@ -1704,7 +1704,7 @@ cleanup_parallel:
result->result = ldap_res; result->result = ldap_res;
} }
} else { } else {
zend_argument_type_error(1, "must be of type LDAP|array, %s given", zend_zval_value_name(link)); zend_argument_type_error(1, "must be of type LDAP\\Connection|array, %s given", zend_zval_value_name(link));
} }
cleanup: cleanup:

View file

@ -11,6 +11,24 @@ $ldap = ldap_connect('ldap://127.0.0.1:3333');
$valid_dn = "cn=userA,something"; $valid_dn = "cn=userA,something";
$valid_filter = ""; $valid_filter = "";
try {
var_dump(ldap_list(42, $valid_dn, $valid_filter));
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump(ldap_list($ldap, [$valid_dn], $valid_filter));
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump(ldap_list($ldap, $valid_dn, [$valid_filter]));
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
$not_list = [ $not_list = [
"attrib1", "attrib1",
"wat" => "attrib2", "wat" => "attrib2",
@ -59,6 +77,9 @@ try {
?> ?>
--EXPECT-- --EXPECT--
TypeError: ldap_list(): Argument #1 ($ldap) must be of type LDAP\Connection|array, int given
TypeError: ldap_list(): Argument #2 ($base) must be of type string when argument #1 ($ldap) is an LDAP\Connection instance
TypeError: ldap_list(): Argument #3 ($filter) must be of type string when argument #1 ($ldap) is an LDAP\Connection instance
ValueError: ldap_list(): Argument #4 ($attributes) must be a list ValueError: ldap_list(): Argument #4 ($attributes) must be a list
TypeError: ldap_list(): Argument #4 ($attributes) must be a list of strings, int given TypeError: ldap_list(): Argument #4 ($attributes) must be a list of strings, int given
ValueError: ldap_list(): Argument #4 ($attributes) must not contain strings with any null bytes ValueError: ldap_list(): Argument #4 ($attributes) must not contain strings with any null bytes

View file

@ -64,5 +64,5 @@ ldap_search(): Argument #4 ($attributes) must be a list
ldap_search(): Argument #1 ($ldap) must not be empty ldap_search(): Argument #1 ($ldap) must not be empty
ldap_search(): Argument #2 ($base) must be the same size as argument #1 ldap_search(): Argument #2 ($base) must be the same size as argument #1
ldap_search(): Argument #3 ($filter) must be the same size as argument #1 ldap_search(): Argument #3 ($filter) must be the same size as argument #1
ldap_search(): Argument #2 ($base) must be of type string when argument #1 ($ldap) is an LDAP instance ldap_search(): Argument #2 ($base) must be of type string when argument #1 ($ldap) is an LDAP\Connection instance
ldap_search(): Argument #3 ($filter) must be of type string when argument #1 ($ldap) is an LDAP instance ldap_search(): Argument #3 ($filter) must be of type string when argument #1 ($ldap) is an LDAP\Connection instance