@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix PHP 8.1 "strlen(null)" exception on LDAP login without password

Summary:
`strlen()` was used in Phabricator to check if a generic value is a non-empty string.
This behavior is deprecated since PHP 8.1. Phorge adopts `phutil_nonempty_string()` as a replacement.

Note: this may highlight other absurd input values that might be worth correcting
instead of just ignoring. If phutil_nonempty_string() throws an exception in your
instance, report it to Phorge to evaluate and fix that specific corner case.

Note: This patch also corrects two further `strlen()` occurrences with the same pattern.

```
ERROR 8192: strlen(): Passing null to parameter #1 ($string) of type string is deprecated at [/var/www/html/phorge/phorge/src/applications/auth/provider/PhabricatorLDAPAuthProvider.php:145]
```

Closes T15893

Test Plan: Create an LDAP user without setting their password; try to log into Phabricator with that user via the LDAP auth provider.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15893

Differential Revision: https://we.phorge.it/D25748

+3 -3
+3 -3
src/applications/auth/provider/PhabricatorLDAPAuthProvider.php
··· 142 142 143 143 $username = $request->getStr('ldap_username'); 144 144 $password = $request->getStr('ldap_password'); 145 - $has_password = strlen($password); 145 + $has_password = phutil_nonempty_string($password); 146 146 $password = new PhutilOpaqueEnvelope($password); 147 147 148 - if (!strlen($username) || !$has_password) { 148 + if (!phutil_nonempty_string($username) || !$has_password) { 149 149 $response = $controller->buildProviderPageResponse( 150 150 $this, 151 151 $this->renderLoginForm($request, 'login')); ··· 154 154 155 155 if ($request->isFormPost()) { 156 156 try { 157 - if (strlen($username) && $has_password) { 157 + if (phutil_nonempty_string($username) && $has_password) { 158 158 $adapter = $this->getAdapter(); 159 159 $adapter->setLoginUsername($username); 160 160 $adapter->setLoginPassword($password);