Skip to content

Commit 4f6c414

Browse files
committed
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 421a734 commit 4f6c414

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
@@ -997,6 +997,10 @@ PHP_FUNCTION(ldap_connect)
997997
ldap_linkdata *ld;
998998
LDAP *ldap = NULL;
999999

1000+
if (ZEND_NUM_ARGS() == 2) {
1001+
zend_error(E_DEPRECATED, "Usage of ldap_connect with two arguments is deprecated.");
1002+
}
1003+
10001004
#ifdef HAVE_ORALDAP
10011005
if (ZEND_NUM_ARGS() == 3 || ZEND_NUM_ARGS() == 4) {
10021006
WRONG_PARAM_COUNT;

ext/ldap/tests/bug73933.phpt

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

2626
?>
2727
--EXPECTF--
28+
Deprecated: Usage of ldap_connect with two arguments is deprecated. in %s on line %d
29+
2830
Warning: ldap_mod_replace(): Modify: Can't contact LDAP server in %sbug73933.php on line %d
2931

3032
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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ $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
resource(%d) of type (ldap link)

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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ try {
1616
echo $e->getMessage(), "\n";
1717
}
1818
?>
19-
--EXPECT--
19+
--EXPECTF--
20+
Deprecated: Usage of ldap_connect with two arguments is deprecated. in %s on line %d
2021
ldap_first_attribute(): supplied resource is not a valid ldap result entry resource

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
@@ -31,6 +31,7 @@ foreach ($controls as $control)
3131
var_dump(ldap_set_option($link, 999999, 999999));
3232
?>
3333
--EXPECTF--
34+
Deprecated: Usage of ldap_connect with two arguments is deprecated. in %s on line %d
3435
bool(false)
3536

3637
Warning: ldap_set_option(): Control must have an oid key in %s on line %d

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)