Skip to content

Commit 1df3ca8

Browse files
committed
ext/ldap: Print correct type
1 parent f22d717 commit 1df3ca8

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
@@ -1646,13 +1646,13 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
16461646
}
16471647

16481648
if (!base_dn_str) {
1649-
zend_argument_type_error(2, "must be of type string when argument #1 ($ldap) is an LDAP instance");
1649+
zend_argument_type_error(2, "must be of type string when argument #1 ($ldap) is an LDAP\\Connection instance");
16501650
ret = 0;
16511651
goto cleanup;
16521652
}
16531653

16541654
if (!filter_str) {
1655-
zend_argument_type_error(3, "must be of type string when argument #1 ($ldap) is an LDAP instance");
1655+
zend_argument_type_error(3, "must be of type string when argument #1 ($ldap) is an LDAP\\Connection instance");
16561656
ret = 0;
16571657
goto cleanup;
16581658
}
@@ -1700,7 +1700,7 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
17001700
result->result = ldap_res;
17011701
}
17021702
} else {
1703-
zend_argument_type_error(1, "must be of type LDAP|array, %s given", zend_zval_value_name(link));
1703+
zend_argument_type_error(1, "must be of type LDAP\\Connection|array, %s given", zend_zval_value_name(link));
17041704
}
17051705

17061706
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",
@@ -60,6 +78,9 @@ try {
6078

6179
?>
6280
--EXPECT--
81+
TypeError: ldap_list(): Argument #1 ($ldap) must be of type LDAP\Connection|array, int given
82+
TypeError: ldap_list(): Argument #2 ($base) must be of type string when argument #1 ($ldap) is an LDAP\Connection instance
83+
TypeError: ldap_list(): Argument #3 ($filter) must be of type string when argument #1 ($ldap) is an LDAP\Connection instance
6384
ValueError: ldap_list(): Argument #4 ($attributes) must be a list
6485
TypeError: ldap_list(): Argument #4 ($attributes) must be a list of strings, int given
6586
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)