Page MenuHomePhorge

Fix PHP 8.1 null parameter exceptions which block rendering the "Browse Projects" overlay dialog

Authored by aklapper on Wed, May 3, 14:00.
Referenced Files
F303939: D25179.diff
Thu, Jun 1, 12:42
Unknown Object (File)
Wed, May 31, 06:33
Unknown Object (File)
Wed, May 31, 05:32
Unknown Object (File)
Mon, May 29, 09:42
Unknown Object (File)
Thu, May 18, 07:20
Unknown Object (File)
Tue, May 16, 19:55
Unknown Object (File)
Fri, May 12, 21:17
"Like" 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.

Note: this may highlight other absurd input values that might be worth correcting
instead of just ignoring. If phutil_nonempty_string() throws an exception in your
instance, report it to Phorge to evaluate and fix that specific corner case.

Similarly, passing null to the $haystack parameter of strpos() is deprecated in PHP 8.1.

Similarly, passing null to the $string parameter of ltrim() is deprecated in PHP 8.1.

Closes part of T15335

Test Plan

Applied these four changes in Phorge (plus the one change in D25180 in Arcanist) and the Browse Projects overlay dialog finally rendered in web browser and listed existing projects.

Diff Detail

rP Phorge
Lint Not Applicable
Tests Not Applicable

Event Timeline

aklapper requested review of this revision.Wed, May 3, 14:00

Thanks for this patch

I start approving this as behalf of myself, but

⏲ I wait before approving as O1 since I imagine at least one person in O1 would say the suggestion shared in PhabricatorProjectDatasource.php line 24


Don't hate me, but I think Evan would love to be able to search by string "0" (currently skipped since it's falsy)


✅ I verified the above line

Note that another known alternative could be:

$description = idx($descriptions, $phid, '');
if ($description !== '') {

But in my honest opinion your already-existing approach is better than the above one and avoids some possible facets.

The function phutil_nonempty_string() will report alien values and that is OK.


✅ Yes, the input string is always a string or null.

The function phutil_nonempty_string() will report alien values and that is OK.


✅ I verified the above line

Yes, we are aware that the if($token) skips the string "0" and it has sense here.

This is valid since a function token must contain a bracket to be valid.


Hi @aklapper, if you change this small line I will immediately +1 since it would be totally OK also from O1 in my opinion

amend small stuff proposed in person to the kind @aklapper


Tested locally following the test plan and something more, no nuclear implosions expected (as I usual say, but this time should be true - as I usual say, but really, this should not cause implosions)


This revision is now accepted and ready to land.Sat, May 20, 15:37