From 1b82943419160bd230b8216b2cba9fa9ddf62da7 Mon Sep 17 00:00:00 2001 From: Andre Klapper Date: Sun, 30 Apr 2023 15:12:30 +0200 Subject: [PATCH] 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 --- .../diffusion/controller/DiffusionController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/applications/diffusion/controller/DiffusionController.php b/src/applications/diffusion/controller/DiffusionController.php index b3595c1b72..aa4f7e3f1e 100644 --- a/src/applications/diffusion/controller/DiffusionController.php +++ b/src/applications/diffusion/controller/DiffusionController.php @@ -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; }