From 0e32dbc1ac8fe6ae03860640520c104fd6f8fe16 Mon Sep 17 00:00:00 2001 From: jkim Date: Tue, 23 May 2023 13:43:33 +0100 Subject: [PATCH] Correct a PHP8 compatibility issue when running "arc diff" with no active branch Summary: When there is no active branch name, arc diff currently fails under PHP8 when we try to strlen(null). This change is also credited to Evan from upstream Phabricator that applied the same change: https://secure.phabricator.com/rARCc39ab20eb3717a15aed2467842bd77d9addce96a 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 T15412 Test Plan: Under PHP 8.1: ran git checkout , then arc diff to generate this revision. Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15412 Differential Revision: https://we.phorge.it/D25237 --- src/workflow/ArcanistDiffWorkflow.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/workflow/ArcanistDiffWorkflow.php b/src/workflow/ArcanistDiffWorkflow.php index 5b8ff40c..f8a627d7 100644 --- a/src/workflow/ArcanistDiffWorkflow.php +++ b/src/workflow/ArcanistDiffWorkflow.php @@ -2361,7 +2361,7 @@ EOTEXT // If we track an upstream branch either directly or indirectly, use that. $branch = $api->getBranchName(); - if (strlen($branch)) { + if (phutil_nonempty_string($branch)) { $upstream_path = $api->getPathToUpstream($branch); $remote_branch = $upstream_path->getRemoteBranchName(); if ($remote_branch !== null) {