From 5d80b3fd88d1b98e6780609207bb93cf39cbbb2e Mon Sep 17 00:00:00 2001 From: Andre Klapper Date: Sat, 19 Aug 2023 10:06:34 +0200 Subject: [PATCH] Fix PHP 8.1 "strlen(null)" exception rendering PHUISegmentBar without a label Summary: `strlen()` was used in Phabricator to check if a generic value is a non-empty string. This behavior 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. ``` EXCEPTION: (RuntimeException) strlen(): Passing null to parameter #1 ($string) of type string is deprecated at [/src/error/PhutilErrorHandler.php:261] arcanist(head=master, ref.master=df6c315ace5f), phorge(head=master, ref.master=3cc5ee6a33df) #0 <#2> PhutilErrorHandler::handleError(integer, string, string, integer) called at [/src/view/phui/PHUISegmentBarView.php:33] ``` Closes T15622 Test Plan: After applying this change, page with the PHUISegmentBar without label renders as expected without an exception. For example, visit this page: /uiexample/view/PhabricatorAphrontBarUIExample/ Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: avivey, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15622 Differential Revision: https://we.phorge.it/D25414 --- src/view/phui/PHUISegmentBarView.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/view/phui/PHUISegmentBarView.php b/src/view/phui/PHUISegmentBarView.php index 632c5327eb..8daa41c203 100644 --- a/src/view/phui/PHUISegmentBarView.php +++ b/src/view/phui/PHUISegmentBarView.php @@ -30,7 +30,7 @@ final class PHUISegmentBarView extends AphrontTagView { require_celerity_resource('phui-segment-bar-view-css'); $label = $this->label; - if (strlen($label)) { + if ($label !== null) { $label = phutil_tag( 'div', array(