Page MenuHomePhorge

Fix PHP 8.1/8.2 "strlen(null)" exception in SearchController

Authored by bob on Aug 8 2023, 08:41.
Referenced Files
F2294950: D25380.1720922936.diff
Sat, Jul 13, 02:08
Unknown Object (File)
Wed, Jul 10, 10:49
Unknown Object (File)
Tue, Jul 9, 11:02
Unknown Object (File)
Tue, Jul 9, 07:02
Unknown Object (File)
Mon, Jul 8, 23:05
Unknown Object (File)
Fri, Jul 5, 14:54
Unknown Object (File)
Thu, Jul 4, 08:37
Unknown Object (File)
Wed, Jul 3, 07:42
"Love" token, awarded by valerio.bozzolan.



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 [<arcanist>/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 [<phorge>/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.

Diff Detail

rP Phorge
Lint Passed
Tests Passed
Build Status
Buildable 734
Build 734: arc lint + arc unit

Event Timeline

bob requested review of this revision.Aug 8 2023, 08:41
This comment was removed by bob.

Sorry for the noise on this diff, I did something wrong during another diff creation procedure (I'm not an arcanist pro since I don't use it in my professional workflow).

valerio.bozzolan edited the test plan for this revision. (Show Details)

Thanks bob! Ready to land

I tested this putting a phplog() in line 15 and using various search pages and I can confirm that the test plan is correct, and this only affects the main search bar, to me.

The only involved values are NULL or a string, and any other thing will trigger our violent screaming system crashing the planet, and we like that.


This revision is now accepted and ready to land.Aug 10 2023, 07:32

Great news, thanks for your review valerio !