Skip to content

Commit d87711b

Browse files
committed
ext/ldap: Print correct type
1 parent 415d93e commit d87711b

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

ext/ldap/ldap.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1650,13 +1650,13 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
16501650
}
16511651

16521652
if (!base_dn_str) {
1653-
zend_argument_type_error(2, "must be of type string when argument #1 ($ldap) is an LDAP instance");
1653+
zend_argument_type_error(2, "must be of type string when argument #1 ($ldap) is an LDAP\\Connection instance");
16541654
ret = 0;
16551655
goto cleanup;
16561656
}
16571657

16581658
if (!filter_str) {
1659-
zend_argument_type_error(3, "must be of type string when argument #1 ($ldap) is an LDAP instance");
1659+
zend_argument_type_error(3, "must be of type string when argument #1 ($ldap) is an LDAP\\Connection instance");
16601660
ret = 0;
16611661
goto cleanup;
16621662
}
@@ -1704,7 +1704,7 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
17041704
result->result = ldap_res;
17051705
}
17061706
} else {
1707-
zend_argument_type_error(1, "must be of type LDAP|array, %s given", zend_zval_value_name(link));
1707+
zend_argument_type_error(1, "must be of type LDAP\\Connection|array, %s given", zend_zval_value_name(link));
17081708
}
17091709

17101710
cleanup:

ext/ldap/tests/ldap_list_read_search_programming_errors.phpt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,24 @@ $ldap = ldap_connect('ldap://127.0.0.1:3333');
1111
$valid_dn = "cn=userA,something";
1212
$valid_filter = "";
1313

14+
try {
15+
var_dump(ldap_list(42, $valid_dn, $valid_filter));
16+
} catch (Throwable $e) {
17+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
18+
}
19+
20+
try {
21+
var_dump(ldap_list($ldap, [$valid_dn], $valid_filter));
22+
} catch (Throwable $e) {
23+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
24+
}
25+
26+
try {
27+
var_dump(ldap_list($ldap, $valid_dn, [$valid_filter]));
28+
} catch (Throwable $e) {
29+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
30+
}
31+
1432
$not_list = [
1533
"attrib1",
1634
"wat" => "attrib2",
@@ -59,6 +77,9 @@ try {
5977

6078
?>
6179
--EXPECT--
80+
TypeError: ldap_list(): Argument #1 ($ldap) must be of type LDAP\Connection|array, int given
81+
TypeError: ldap_list(): Argument #2 ($base) must be of type string when argument #1 ($ldap) is an LDAP\Connection instance
82+
TypeError: ldap_list(): Argument #3 ($filter) must be of type string when argument #1 ($ldap) is an LDAP\Connection instance
6283
ValueError: ldap_list(): Argument #4 ($attributes) must be a list
6384
TypeError: ldap_list(): Argument #4 ($attributes) must be a list of strings, int given
6485
ValueError: ldap_list(): Argument #4 ($attributes) must not contain strings with any null bytes

ext/ldap/tests/ldap_search_error.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,5 @@ ldap_search(): Argument #4 ($attributes) must be a list
6464
ldap_search(): Argument #1 ($ldap) must not be empty
6565
ldap_search(): Argument #2 ($base) must be the same size as argument #1
6666
ldap_search(): Argument #3 ($filter) must be the same size as argument #1
67-
ldap_search(): Argument #2 ($base) must be of type string when argument #1 ($ldap) is an LDAP instance
68-
ldap_search(): Argument #3 ($filter) must be of type string when argument #1 ($ldap) is an LDAP instance
67+
ldap_search(): Argument #2 ($base) must be of type string when argument #1 ($ldap) is an LDAP\Connection instance
68+
ldap_search(): Argument #3 ($filter) must be of type string when argument #1 ($ldap) is an LDAP\Connection instance

0 commit comments

Comments
 (0)