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
F3539822: D25380.1744896180.diff
Wed, Apr 16, 13:23
F3506106: D25380.1744800125.diff
Tue, Apr 15, 10:42
F3394701: D25380.1744509801.diff
Sat, Apr 12, 02:03
F3388103: D25380.1744444535.diff
Fri, Apr 11, 07:55
F3385468: D25380.1744417720.diff
Fri, Apr 11, 00:28
F3372525: D25380.1744250204.diff
Wed, Apr 9, 01:56
F3372465: D25380.1744249962.diff
Wed, Apr 9, 01:52
F3371661: D25380.1744244660.diff
Wed, Apr 9, 00:24
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 !