Page MenuHomePhorge

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

Authored by bob on Aug 8 2023, 08:41.
Tags
None
Referenced Files
Unknown Object (File)
Fri, May 10, 00:14
Unknown Object (File)
Fri, May 10, 00:14
Unknown Object (File)
Fri, May 10, 00:14
Unknown Object (File)
Fri, May 10, 00:14
Unknown Object (File)
Fri, May 10, 00:14
Unknown Object (File)
Wed, May 8, 07:58
Unknown Object (File)
Wed, May 8, 07:32
Unknown Object (File)
Thu, May 2, 09:55
Tokens
"Love" token, awarded by valerio.bozzolan.

Details

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 [<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

Repository
rP Phorge
Lint
Lint Not Applicable
Unit
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.

sgtm

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

Great news, thanks for your review valerio !