From dff04ba91d45307143cae47cd43a73ae4e067423 Mon Sep 17 00:00:00 2001 From: Andre Klapper Date: Mon, 1 May 2023 22:26:09 +0200 Subject: [PATCH] Fix some PHP 8.1 "strlen(null)" exceptions which block rendering a project 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 T15313 Test Plan: Applied these three changes (with D25144, D25145, D25146, D25147, D25151, D25152, D25153 on top). Afterwards end up with the unresolved exception covered by T15263. Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15313 Differential Revision: https://we.phorge.it/D25163 --- .../project/state/PhabricatorWorkboardViewState.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/applications/project/state/PhabricatorWorkboardViewState.php b/src/applications/project/state/PhabricatorWorkboardViewState.php index 04f8498d49..0d5d94f1f2 100644 --- a/src/applications/project/state/PhabricatorWorkboardViewState.php +++ b/src/applications/project/state/PhabricatorWorkboardViewState.php @@ -41,7 +41,7 @@ final class PhabricatorWorkboardViewState $this->requestState['filter'] = $request->getStr('filter'); } - if (strlen($request->getURIData('queryKey'))) { + if (phutil_nonempty_string($request->getURIData('queryKey'))) { $this->requestState['filter'] = $request->getURIData('queryKey'); } @@ -169,7 +169,7 @@ final class PhabricatorWorkboardViewState public function getQueryKey() { $request_query = idx($this->requestState, 'filter'); - if (strlen($request_query)) { + if (phutil_nonempty_string($request_query)) { return $request_query; } @@ -203,7 +203,7 @@ final class PhabricatorWorkboardViewState $default_query = $project->getDefaultWorkboardFilter(); - if (strlen($default_query)) { + if (phutil_nonempty_string($default_query)) { return $default_query; }