Skip to content

Commit 3c56199

Browse files
heiglandreascmb69
authored andcommitted
Deprecate ldap_connect with two parameters
ldap_connect should be called with an LDAP-URI as parameter and not with 2 parameters as that allows much more flexibility like differentiating between ldap and ldaps or setting multiple ldap-servers. This change requires one to add null as second parameter in case the underlying library is Oracle and one wants to add wallet-details.
1 parent 42c5712 commit 3c56199

19 files changed

+40
-14
lines changed

ext/ldap/ldap.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,10 @@ PHP_FUNCTION(ldap_connect)
925925
ldap_linkdata *ld;
926926
LDAP *ldap = NULL;
927927

928+
if (ZEND_NUM_ARGS() == 2) {
929+
zend_error(E_DEPRECATED, "Usage of ldap_connect with two arguments is deprecated.");
930+
}
931+
928932
#ifdef HAVE_ORALDAP
929933
if (ZEND_NUM_ARGS() == 3 || ZEND_NUM_ARGS() == 4) {
930934
WRONG_PARAM_COUNT;

ext/ldap/tests/bug73933.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ ldap_close($ldap);
2222

2323
?>
2424
--EXPECTF--
25+
Deprecated: Usage of ldap_connect with two arguments is deprecated. in %s on line %d
26+
2527
Warning: ldap_mod_replace(): Modify: Can't contact LDAP server in %sbug73933.php on line %d
2628

2729
Warning: ldap_modify_batch(): Batch Modify: Can't contact LDAP server in %sbug73933.php on line %d

ext/ldap/tests/ldap_connect_basic.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ $link = ldap_connect($host, $port);
1313
var_dump($link);
1414
?>
1515
--EXPECTF--
16+
Deprecated: Usage of ldap_connect with two arguments is deprecated. in %s on line %d
1617
object(LDAP\Connection)#%d (0) {
17-
}
18+
}

ext/ldap/tests/ldap_connect_error.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,8 @@ $links[1] = ldap_connect($host, $port);
2222
Warning: ldap_connect(): Could not create session handle: %s in %s on line %d
2323
bool(false)
2424

25+
Deprecated: Usage of ldap_connect with two arguments is deprecated. in %s on line %d
26+
27+
Deprecated: Usage of ldap_connect with two arguments is deprecated. in %s on line %d
28+
2529
Warning: ldap_connect(): Too many open links (1) in %s on line %d

ext/ldap/tests/ldap_first_attribute_error.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ try {
1717
}
1818
?>
1919
--EXPECT--
20+
Deprecated: Usage of ldap_connect with two arguments is deprecated. in %s on line %d
2021
ldap_first_attribute(): Argument #2 ($entry) must be of type LDAP\ResultEntry, LDAP\Connection given

ext/ldap/tests/ldap_get_option_basic.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ var_dump(
1818
$option
1919
);
2020
?>
21-
--EXPECT--
21+
--EXPECTF--
22+
Deprecated: Usage of ldap_connect with two arguments is deprecated. in %s on line %d
2223
bool(true)
2324
int(3)

ext/ldap/tests/ldap_get_option_package_basic.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ var_dump(in_array($optionval, ['GnuTLS', 'OpenSSL', 'MozNSS']));
1414
// This is a read-only option.
1515
var_dump(ldap_set_option($link, LDAP_OPT_X_TLS_PACKAGE, 'foo'));
1616
?>
17-
--EXPECT--
17+
--EXPECTF--
18+
Deprecated: Usage of ldap_connect with two arguments is deprecated. in %s on line %d
1819
bool(true)
1920
bool(false)

ext/ldap/tests/ldap_get_option_variation.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ var_dump(
4848
$option
4949
);
5050
?>
51-
--EXPECT--
51+
--EXPECTF--
52+
Deprecated: Usage of ldap_connect with two arguments is deprecated. in %s on line %d
5253
bool(true)
5354
int(0)
5455
bool(true)

ext/ldap/tests/ldap_rename_error.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ require "connect.inc";
1212
$link = ldap_connect($host, $port);
1313
var_dump(ldap_rename($link, "cn=userNotFound,$base", "cn=userZ", "$base", true));
1414
?>
15-
--EXPECT--
15+
--EXPECTF--
16+
Deprecated: Usage of ldap_connect with two arguments is deprecated. in %s on line %d
1617
bool(false)

ext/ldap/tests/ldap_set_option_basic.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ var_dump(ldap_set_option($link, LDAP_OPT_PROTOCOL_VERSION, $protocol_version));
1616
ldap_get_option($link, LDAP_OPT_PROTOCOL_VERSION, $option);
1717
var_dump($option);
1818
?>
19-
--EXPECT--
19+
--EXPECTF--
20+
Deprecated: Usage of ldap_connect with two arguments is deprecated. in %s on line %d
2021
bool(true)
2122
int(3)

ext/ldap/tests/ldap_set_option_cafiles_basic.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ foreach([
2424
var_dump($optionval);
2525
}
2626
?>
27-
--EXPECT--
27+
--EXPECTF--
28+
Deprecated: Usage of ldap_connect with two arguments is deprecated. in %s on line %d
2829
bool(true)
2930
string(8) "/foo/bar"
3031
bool(true)

ext/ldap/tests/ldap_set_option_ciphersuite_basic.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ var_dump($result);
1515
ldap_get_option($link, LDAP_OPT_X_TLS_CIPHER_SUITE, $optionval);
1616
var_dump($optionval);
1717
?>
18-
--EXPECT--
18+
--EXPECTF--
19+
Deprecated: Usage of ldap_connect with two arguments is deprecated. in %s on line %d
1920
bool(true)
2021
string(4) "3DES"

ext/ldap/tests/ldap_set_option_crlcheck_error.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ $link = ldap_connect($host, $port);
1111
$result = ldap_set_option($link, LDAP_OPT_X_TLS_CRLCHECK, 9001);
1212
var_dump($result);
1313
?>
14-
--EXPECT--
14+
--EXPECTF--
15+
Deprecated: Usage of ldap_connect with two arguments is deprecated. in %s on line %d
1516
bool(false)

ext/ldap/tests/ldap_set_option_error.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ foreach ($controls as $control) {
3636
var_dump(ldap_set_option($link, 999999, 999999));
3737
?>
3838
--EXPECT--
39+
Deprecated: Usage of ldap_connect with two arguments is deprecated. in %s on line %d
3940
bool(false)
4041
ValueError: ldap_set_option(): Control must have an "oid" key
4142
TypeError: ldap_set_option(): Argument #3 ($value) must contain only arrays, where each array is a control

ext/ldap/tests/ldap_set_option_keepalive_basic.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ foreach([
2121
var_dump($optionval);
2222
}
2323
?>
24-
--EXPECT--
24+
--EXPECTF--
25+
Deprecated: Usage of ldap_connect with two arguments is deprecated. in %s on line %d
2526
bool(true)
2627
int(5)
2728
bool(true)

ext/ldap/tests/ldap_set_option_reqcert_basic.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ foreach([
2323
var_dump($optionval);
2424
}
2525
?>
26-
--EXPECT--
26+
--EXPECTF--
27+
Deprecated: Usage of ldap_connect with two arguments is deprecated. in %s on line %d
2728
bool(true)
2829
int(0)
2930
bool(true)

ext/ldap/tests/ldap_set_option_reqcert_error.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ $link = ldap_connect($host, $port);
1111
$result = ldap_set_option($link, LDAP_OPT_X_TLS_REQUIRE_CERT, 9001);
1212
var_dump($result);
1313
?>
14-
--EXPECT--
14+
--EXPECTF--
15+
Deprecated: Usage of ldap_connect with two arguments is deprecated. in %s on line %d
1516
bool(false)

ext/ldap/tests/ldap_set_option_tls_protocol_min_basic.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ foreach([
2323
var_dump($optionval);
2424
}
2525
?>
26-
--EXPECT--
26+
--EXPECTF--
27+
Deprecated: Usage of ldap_connect with two arguments is deprecated. in %s on line %d
2728
bool(true)
2829
int(512)
2930
bool(true)

ext/ldap/tests/ldap_set_option_variation.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ var_dump(
6161
ldap_get_option($link, LDAP_OPT_MATCHED_DN, $option);
6262
var_dump($option);
6363
?>
64-
--EXPECT--
64+
--EXPECTF--
65+
Deprecated: Usage of ldap_connect with two arguments is deprecated. in %s on line %d
6566
bool(true)
6667
bool(true)
6768
bool(true)

0 commit comments

Comments
 (0)