1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-04 20:52:43 +01:00

Fix PHP 8.3 "Usage of ldap_connect with two arguments is deprecated" exception

Summary:
Per https://www.php.net/manual/en/function.ldap-connect.php the signature `$conn = @ldap_connect($host, $this->port);` is deprecated since PHP 8.3.
Thus pass a full LDAP URI as the only parameter.

```
ERROR 8192: Usage of ldap_connect with two arguments is deprecated at [/var/www/html/phorge/phorge/src/applications/auth/adapter/PhutilLDAPAuthAdapter.php:308]
```

Closes T15724

Test Plan: Set up LDAP as auth provider, try to log in.

Reviewers: O1 Blessed Committers, avivey

Reviewed By: O1 Blessed Committers, avivey

Subscribers: avivey, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15724

Differential Revision: https://we.phorge.it/D25792
This commit is contained in:
Andre Klapper 2024-08-19 21:48:17 +02:00
parent c0ebc7b405
commit 700090917a

View file

@ -305,7 +305,12 @@ final class PhutilLDAPAuthAdapter extends PhutilAuthAdapter {
'port' => $this->port, 'port' => $this->port,
)); ));
$conn = @ldap_connect($host, $this->port); if ($this->ldapStartTLS) {
$ldap_server_uri = 'ldaps://'.$host.':'.$this->port;
} else {
$ldap_server_uri = 'ldap://'.$host.':'.$this->port;
}
$conn = @ldap_connect($ldap_server_uri);
$profiler->endServiceCall( $profiler->endServiceCall(
$call_id, $call_id,
@ -315,7 +320,7 @@ final class PhutilLDAPAuthAdapter extends PhutilAuthAdapter {
if (!$conn) { if (!$conn) {
throw new Exception( throw new Exception(
pht('Unable to connect to LDAP server (%s:%d).', $host, $port)); pht('Unable to connect to LDAP server (%s).', $ldap_server_uri));
} }
$options = array( $options = array(