From cf8d5d60a594f2f172450879327caac0f0e6afc8 Mon Sep 17 00:00:00 2001 From: bob Date: Wed, 22 Nov 2023 16:56:01 +0100 Subject: [PATCH] Fix a PHP 8.1 deprecated use of strlen with a NULL argument in commit parser Summary: With PHP 8.1+ it is not possible to import a commit if the commiter field is not properly defined Indeed, if the committer is not properly defined, strlen(null) is called, causing a deprecation warning, elevated to exception. Using strlen() to check string validity is deprecated since PHP 8.1. Phorge adopts phutil_nonempty_string() as a replacement. Fix T15629 Test Plan: - Push a commit to an observed subversion repository - Import it via the phorge/bin/repository reparse COMMIT_ID --importing - The commit should be properly imported and available in Diffusion Reviewers: O1 Blessed Committers, Sten, valerio.bozzolan Reviewed By: O1 Blessed Committers, Sten, valerio.bozzolan Subscribers: Sten, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15629 Differential Revision: https://we.phorge.it/D25423 --- .../PhabricatorRepositoryCommitMessageParserWorker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php b/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php index a0ea2d84b2..fc0bd42477 100644 --- a/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php +++ b/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php @@ -36,7 +36,7 @@ abstract class PhabricatorRepositoryCommitMessageParserWorker $author = $ref->getAuthor(); $committer = $ref->getCommitter(); - $has_committer = (bool)strlen($committer); + $has_committer = phutil_nonempty_string($committer); $identity_engine = id(new DiffusionRepositoryIdentityEngine()) ->setViewer($viewer)