Page MenuHomePhorge

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

Authored by bob on Aug 8 2023, 08:41.
Referenced Files
Unknown Object (File)
Thu, Sep 21, 09:48
Unknown Object (File)
Thu, Sep 21, 05:51
Unknown Object (File)
Mon, Sep 18, 00:37
Unknown Object (File)
Mon, Sep 4, 11:32
Unknown Object (File)
Mon, Sep 4, 09:28
Unknown Object (File)
Sun, Sep 3, 17:53
Unknown Object (File)
Sun, Sep 3, 15:40
Unknown Object (File)
Mon, Aug 28, 06:37
"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 Not Applicable
Tests Not Applicable

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 !