From 5bd526646144e062f7c68e15ba07d03e6047adb6 Mon Sep 17 00:00:00 2001 From: bob Date: Wed, 22 Nov 2023 16:53:55 +0100 Subject: [PATCH] Fix a PHP 8.1 deprecated use of strlen with a NULL argument Summary: This call prevents users to view a commit in subversion repositories Indeed, if commiter and/or author field is not properly defined strlen is call with a NULL argument. Using strlen to check string validity 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. Fix T15610 Test Plan: - Sign in (if needed) - Open a diffusion SVN repository - Open a commit without user name and or email - You should be able to view the commit Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15610 Differential Revision: https://we.phorge.it/D25400 --- .../repository/storage/PhabricatorRepositoryCommit.php | 4 ++-- .../repository/storage/PhabricatorRepositoryCommitData.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/applications/repository/storage/PhabricatorRepositoryCommit.php b/src/applications/repository/storage/PhabricatorRepositoryCommit.php index 9e20a36676..ef3657d49f 100644 --- a/src/applications/repository/storage/PhabricatorRepositoryCommit.php +++ b/src/applications/repository/storage/PhabricatorRepositoryCommit.php @@ -478,7 +478,7 @@ final class PhabricatorRepositoryCommit } $author = $this->getRawAuthorStringForDisplay(); - if (strlen($author)) { + if (phutil_nonempty_string($author)) { return DiffusionView::renderName($author); } @@ -493,7 +493,7 @@ final class PhabricatorRepositoryCommit } $committer = $this->getRawCommitterStringForDisplay(); - if (strlen($committer)) { + if (phutil_nonempty_string($committer)) { return DiffusionView::renderName($committer); } diff --git a/src/applications/repository/storage/PhabricatorRepositoryCommitData.php b/src/applications/repository/storage/PhabricatorRepositoryCommitData.php index c77da64ec2..4726658b7a 100644 --- a/src/applications/repository/storage/PhabricatorRepositoryCommitData.php +++ b/src/applications/repository/storage/PhabricatorRepositoryCommitData.php @@ -131,7 +131,7 @@ final class PhabricatorRepositoryCommitData extends PhabricatorRepositoryDAO { $ref = $this->getCommitRef(); $committer = $ref->getCommitter(); - if (strlen($committer)) { + if (phutil_nonempty_string($committer)) { return $committer; }