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 the Diffusion 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.

Closes T15300

Test Plan: Applied these three changes (on top of D25144, D25145, D25146, D25147) and `/diffusion/` finally rendered in web browser.

Reviewers: O1 Blessed Committers, avivey

Reviewed By: O1 Blessed Committers, avivey

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

Maniphest Tasks: T15300

Differential Revision: https://we.phorge.it/D25150
This commit is contained in:
Andre Klapper 2023-04-30 15:12:30 +02:00
parent 562d36ef5f
commit 1b82943419

View file

@ -97,19 +97,19 @@ abstract class DiffusionController extends PhabricatorController {
AphrontRequest $request) {
$short_name = $request->getURIData('repositoryShortName');
if (strlen($short_name)) {
if (phutil_nonempty_string($short_name)) {
// If the short name ends in ".git", ignore it.
$short_name = preg_replace('/\\.git\z/', '', $short_name);
return $short_name;
}
$identifier = $request->getURIData('repositoryCallsign');
if (strlen($identifier)) {
if (phutil_nonempty_string($identifier)) {
return $identifier;
}
$id = $request->getURIData('repositoryID');
if (strlen($id)) {
if (phutil_nonempty_string($id)) {
return (int)$id;
}