From 444bb60d432539a987ecb6dfc4e9cef6c4c02537 Mon Sep 17 00:00:00 2001 From: Valerio Bozzolan Date: Thu, 1 Jun 2023 18:19:46 +0200 Subject: [PATCH] Fix PHP 8.1 "strlen(null)" exception from ArcanistRefView which blocks "arc look remotes" Summary: This change fixes the command `arc look remotes` for PHP 8.1. Without this change, the null value bubbles up to PhutilUTF8StringTruncator, reaching a strlen(). This control probably does not need to be done at this low level inside PhutilUTF8StringTruncator, but it is right to be at this high level from the caller in ArcanistRefView. Closes T15368 Test Plan: - run "arc look remotes" - still works in "old PHP" like 7.4 - start to work in recent PHP 8.1+ Reviewers: O1 Blessed Committers, avivey Reviewed By: O1 Blessed Committers, avivey Subscribers: avivey, speck, tobiaswiese, Matthew, Cigaryno Maniphest Tasks: T15368 Differential Revision: https://we.phorge.it/D25206 --- src/ref/ArcanistRefView.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ref/ArcanistRefView.php b/src/ref/ArcanistRefView.php index bb166aca..e99953c2 100644 --- a/src/ref/ArcanistRefView.php +++ b/src/ref/ArcanistRefView.php @@ -72,6 +72,11 @@ final class ArcanistRefView $object_name = $this->getObjectName(); $title = $this->getTitle(); + // Our goal here is to work with strings, defaults or not + if ($title === null) { + $title = ''; + } + if ($object_name !== null) { $reserve_width = phutil_utf8_console_strlen($object_name) + 1; } else {