1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 14:52:41 +01:00

Fix PHP 8.1 "strlen(null)" exceptions which block rendering Log In page after user logout

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.

Closes T15384

Test Plan: Applied these four changes; logged in again; logged out again; finally saw "Log In" page with "Username or Email" and "Password" field on `/auth/loggedout/` rendered in web browser.

Reviewers: O1 Blessed Committers, avivey

Reviewed By: O1 Blessed Committers, avivey

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

Maniphest Tasks: T15384

Differential Revision: https://we.phorge.it/D25217
This commit is contained in:
Andre Klapper 2023-05-12 12:02:54 +02:00
parent 3a3112f67b
commit 4d1adf6939
3 changed files with 4 additions and 4 deletions

View file

@ -89,7 +89,7 @@ final class PhabricatorCookies extends Phobject {
// temporary and clearing it when users log out. // temporary and clearing it when users log out.
$value = $request->getCookie(self::COOKIE_CLIENTID); $value = $request->getCookie(self::COOKIE_CLIENTID);
if (!strlen($value)) { if (!phutil_nonempty_string($value)) {
$request->setTemporaryCookie( $request->setTemporaryCookie(
self::COOKIE_CLIENTID, self::COOKIE_CLIENTID,
Filesystem::readRandomCharacters(16)); Filesystem::readRandomCharacters(16));

View file

@ -282,7 +282,7 @@ abstract class PhabricatorAuthController extends PhabricatorController {
$viewer, $viewer,
PhabricatorAuthLoginMessageType::MESSAGEKEY); PhabricatorAuthLoginMessageType::MESSAGEKEY);
if (!strlen($text)) { if (!phutil_nonempty_string($text)) {
return null; return null;
} }

View file

@ -98,7 +98,7 @@ final class PhabricatorAuthStartController
} }
$next_uri = $request->getStr('next'); $next_uri = $request->getStr('next');
if (!strlen($next_uri)) { if (!phutil_nonempty_string($next_uri)) {
if ($this->getDelegatingController()) { if ($this->getDelegatingController()) {
// Only set a next URI from the request path if this controller was // Only set a next URI from the request path if this controller was
// delegated to, which happens when a user tries to view a page which // delegated to, which happens when a user tries to view a page which
@ -112,7 +112,7 @@ final class PhabricatorAuthStartController
} }
if (!$request->isFormPost()) { if (!$request->isFormPost()) {
if (strlen($next_uri)) { if (phutil_nonempty_string($next_uri)) {
PhabricatorCookies::setNextURICookie($request, $next_uri); PhabricatorCookies::setNextURICookie($request, $next_uri);
} }
PhabricatorCookies::setClientIDCookie($request); PhabricatorCookies::setClientIDCookie($request);