From 6ec89e9f08668c950c6a7d80164bd822bd38b472 Mon Sep 17 00:00:00 2001 From: bob Date: Fri, 18 Aug 2023 12:48:02 +0200 Subject: [PATCH] Fix a PHP 8.1 deprecated use of strlen with a NULL argument Summary: With PHP 8.1+ it was not possible to view a commit from subversion repositories. Indeed, if the commit user and/or email 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. 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 T15609 Test Plan: - Apply D25397 and D25398 - Sign in - Open a diffusion SVN repository - Open a commit without user name and or email - You should not see the same Runtime Exception (unfortunately, there is another one as described in T15610) Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15609 Differential Revision: https://we.phorge.it/D25399 --- src/applications/diffusion/data/DiffusionCommitRef.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/applications/diffusion/data/DiffusionCommitRef.php b/src/applications/diffusion/data/DiffusionCommitRef.php index 06dd4d5ffb..76c3371192 100644 --- a/src/applications/diffusion/data/DiffusionCommitRef.php +++ b/src/applications/diffusion/data/DiffusionCommitRef.php @@ -131,6 +131,8 @@ final class DiffusionCommitRef extends Phobject { } private function formatUser($name, $email) { + $name = coalesce($name, ''); + $email = coalesce($email, ''); if (strlen($name) && strlen($email)) { return "{$name} <{$email}>"; } else if (strlen($email)) {