Page MenuHomePhorge

Fix PHP 8.1 "strlen(null)" exception which blocks rendering a config page

Authored by aklapper on May 3 2023, 16:58.
Referenced Files
Unknown Object (File)
Fri, Jun 2, 22:07
Unknown Object (File)
Wed, May 31, 06:34
Unknown Object (File)
Tue, May 23, 07:33
Unknown Object (File)
Tue, May 23, 00:03
Unknown Object (File)
Mon, May 22, 20:36
Unknown Object (File)
Sun, May 21, 14:51
Unknown Object (File)
Wed, May 17, 17:45



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.

Closes T15336

Test Plan

Applied this change and /config/edit/load-libraries/ correctly rendered in web browser.

Diff Detail

rP Phorge
Lint Not Applicable
Tests Not Applicable

Event Timeline

aklapper requested review of this revision.May 3 2023, 16:58

Thank you so much also for this patch!

I tested this locally, examining $description with pht() and testing both in PHP 7.4 and PHP 8.1, following the test plan and some other things, opening very random Configs, without any unexpected nuclear implosion.

The function phutil_nonempty_string() will report any value that is not null and is not a string, and that is OK.

Hoping to be useful I will also add a bit PHPDoc so to help other people to understand the internals of this description that is a String that contains raw Remarkup, and it's never a PHUIRemarkupView since it builds that.

Green light



✅ Note that $description must be a string (and not some fancy string builders) since the example declared in PHUIRemarkupView.php is

$fancy_text = new PHUIRemarkupView($viewer, $raw_remarkup);
This revision is now accepted and ready to land.May 4 2023, 06:55

hoping to be useful, add PHPDoc to clarify that the description is always raw remarkup (string) or null