[php-src] PHP-8.4: ldap: Fix the ldap_set_option() controls type error naming the wrong option (#25502)
| From: | Louis-Arnaud via GitHub | Date: | Tue, 17 Nov 2026 08:40:18 +0000 |
| Subject: | [php-src] PHP-8.4: ldap: Fix the ldap_set_option() controls type error naming the wrong option (#25502) | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-143755@lists.php.net to get a copy of this message | ||
Author: Louis-Arnaud (lacatoire)
Committer: GitHub (web-flow)
Pusher: TimWolla
Date: 2026-11-17T09:40:14+01:00
Commit: https://github.com/php/php-src/commit/fac5881398c199f552882cbebaa1cbdad528c657
Raw diff: https://github.com/php/php-src/commit/fac5881398c199f552882cbebaa1cbdad528c657.diff
ldap: Fix the ldap_set_option() controls type error naming the wrong option (#25502)
Changed paths:
A ext/ldap/tests/ldap_set_option_controls_type_error.phpt
M ext/ldap/ldap.c
M ext/ldap/tests/ldap_set_option_error.phpt
Diff:
diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c
index 4c9466749ea8..ca9e5fc2202e 100644
--- a/ext/ldap/ldap.c
+++ b/ext/ldap/ldap.c
@@ -3365,7 +3365,9 @@ PHP_FUNCTION(ldap_set_option)
int rc;
if (Z_TYPE_P(newval) != IS_ARRAY) {
- zend_argument_type_error(3, "must be of type array for the LDAP_OPT_CLIENT_CONTROLS
option, %s given", zend_zval_value_name(newval));
+ zend_argument_type_error(3, "must be of type array for the %s option, %s given",
+ option == LDAP_OPT_SERVER_CONTROLS ? "LDAP_OPT_SERVER_CONTROLS" :
"LDAP_OPT_CLIENT_CONTROLS",
+ zend_zval_value_name(newval));
RETURN_THROWS();
}
diff --git a/ext/ldap/tests/ldap_set_option_controls_type_error.phpt
b/ext/ldap/tests/ldap_set_option_controls_type_error.phpt
new file mode 100644
index 000000000000..c910d8445bc5
--- /dev/null
+++ b/ext/ldap/tests/ldap_set_option_controls_type_error.phpt
@@ -0,0 +1,18 @@
+--TEST--
+ldap_set_option(): the type error for the controls options names the option
+--EXTENSIONS--
+ldap
+--FILE--
+<?php
+$l = ldap_connect('ldap://127.0.0.1:1');
+foreach ([LDAP_OPT_SERVER_CONTROLS, LDAP_OPT_CLIENT_CONTROLS] as $option) {
+ try {
+ ldap_set_option($l, $option, "x");
+ } catch (Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), "\n";
+ }
+}
+?>
+--EXPECT--
+TypeError: ldap_set_option(): Argument #3 ($value) must be of type array for the
LDAP_OPT_SERVER_CONTROLS option, string given
+TypeError: ldap_set_option(): Argument #3 ($value) must be of type array for the
LDAP_OPT_CLIENT_CONTROLS option, string given
diff --git a/ext/ldap/tests/ldap_set_option_error.phpt b/ext/ldap/tests/ldap_set_option_error.phpt
index fa66e348c46b..f784524fce23 100644
--- a/ext/ldap/tests/ldap_set_option_error.phpt
+++ b/ext/ldap/tests/ldap_set_option_error.phpt
@@ -39,5 +39,5 @@ var_dump(ldap_set_option($link, 999999, 999999));
bool(false)
ValueError: ldap_set_option(): Control must have an "oid" key
TypeError: ldap_set_option(): Argument #3 ($value) must contain only arrays, where each array is a
control
-TypeError: ldap_set_option(): Argument #3 ($value) must be of type array for the
LDAP_OPT_CLIENT_CONTROLS option, string given
+TypeError: ldap_set_option(): Argument #3 ($value) must be of type array for the
LDAP_OPT_SERVER_CONTROLS option, string given
bool(false)