Commit fac5881398c for php
commit fac5881398c199f552882cbebaa1cbdad528c657
Author: Louis-Arnaud <la.catoire@gmail.com>
Date: Tue Nov 17 09:40:14 2026 +0100
ldap: Fix the ldap_set_option() controls type error naming the wrong option (#25502)
diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c
index 4c9466749ea..ca9e5fc2202 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 00000000000..c910d8445bc
--- /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 fa66e348c46..f784524fce2 100644
--- a/ext/ldap/tests/ldap_set_option_error.phpt
+++ b/ext/ldap/tests/ldap_set_option_error.phpt
@@ -39,5 +39,5 @@
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)