From eb2be08f9f0e1656e31f68c2c701bf026c7f5050 Mon Sep 17 00:00:00 2001 From: bob Date: Thu, 10 Aug 2023 17:40:31 +0200 Subject: [PATCH] Fix PHP 8.1/8.2 "strlen(null)" exception in SearchController 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. EXCEPTION: (RuntimeException) strlen(): Passing null to parameter #1 ($string) of type string is deprecated at [/src/error/PhutilErrorHandler.php:261]; PHP message: arcanist(head=master, ref.master=6e4947b55f09), phorge(head=master, ref.master=7bebfa289aa1); PHP message: #0 <#2> PhutilErrorHandler::handleError(integer, string, string, integer) called at [/src/applications/search/controller/PhabricatorSearchController.php:16]; Fix T15595 Test Plan: Search something using the main search bar. It should return something (or not) instead to throwing a RuntimeException. Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15595 Differential Revision: https://we.phorge.it/D25380 --- .../search/controller/PhabricatorSearchController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/applications/search/controller/PhabricatorSearchController.php b/src/applications/search/controller/PhabricatorSearchController.php index b3d3ab18fa..336604d228 100644 --- a/src/applications/search/controller/PhabricatorSearchController.php +++ b/src/applications/search/controller/PhabricatorSearchController.php @@ -13,7 +13,7 @@ final class PhabricatorSearchController $viewer = $this->getViewer(); $query = $request->getStr('query'); - if ($request->getStr('jump') != 'no' && strlen($query)) { + if ($request->getStr('jump') != 'no' && phutil_nonempty_string($query)) { $jump_uri = id(new PhabricatorDatasourceEngine()) ->setViewer($viewer) ->newJumpURI($query);