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
F3292213: D25380.1742888136.diff
Mon, Mar 24, 07:35
F3292052: D25380.1742886635.diff
Mon, Mar 24, 07:10
F3250201: D25380.1742297504.diff
Mon, Mar 17, 11:31
F3248293: D25380.1742248777.diff
Sun, Mar 16, 21:59
F3225052: D25380.1742090306.diff
Sat, Mar 15, 01:58
F3220743: D25380.1741813087.diff
Tue, Mar 11, 20:58
F3220742: D25380.1741813086.diff
Tue, Mar 11, 20:58
F3220741: D25380.1741813085.diff
Tue, Mar 11, 20:58
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 !