1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Fix PHP 8.1 "strlen(null)" and "explode()" exceptions which block rendering Administrator Account Creation page

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.

Similarly, `explode(string $separator, string $string, int $limit)` does not accept
passing null instead of an actual string as input parameter either anymore.

Closes T15284

Test Plan: Applied these two changes. Afterwards, admin user account was created and Phorge homepage rendered in web browser on a fresh installation.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

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

Maniphest Tasks: T15284

Differential Revision: https://we.phorge.it/D25175
This commit is contained in:
Andre Klapper 2023-05-19 16:59:07 +02:00
parent 402a63c5de
commit 8a1cfff1e8
2 changed files with 4 additions and 1 deletions

View file

@ -164,7 +164,7 @@ final class PhabricatorCookies extends Phobject {
// Old cookies look like: /uri // Old cookies look like: /uri
// New cookies look like: timestamp,/uri // New cookies look like: timestamp,/uri
if (!strlen($cookie)) { if (!phutil_nonempty_string($cookie)) {
return null; return null;
} }

View file

@ -91,6 +91,9 @@ final class PhabricatorUserProfileImageCacheType
} }
public function isRawCacheDataValid(PhabricatorUser $user, $key, $data) { public function isRawCacheDataValid(PhabricatorUser $user, $key, $data) {
if ($data === null) {
return false;
}
$parts = explode(',', $data, 2); $parts = explode(',', $data, 2);
$version = reset($parts); $version = reset($parts);
return ($version === $this->getCacheVersion($user)); return ($version === $this->getCacheVersion($user));