Page MenuHomePhorge

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

Authored by aklapper on May 3 2023, 16:58.
Tags
None
Referenced Files
F3290718: D25181.1742871106.diff
Mon, Mar 24, 02:51
F3290338: D25181.1742863345.diff
Mon, Mar 24, 00:42
F3290082: D25181.1742858574.diff
Sun, Mar 23, 23:22
F3287339: D25181.1742819340.diff
Sun, Mar 23, 12:29
F3283531: D25181.1742753761.diff
Sat, Mar 22, 18:16
F3252545: D25181.1742391628.diff
Tue, Mar 18, 13:40
F3220823: D25181.1741813151.diff
Tue, Mar 11, 20:59
F3220818: D25181.1741813147.diff
Tue, Mar 11, 20:59

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.

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

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

sgtm

src/applications/config/option/PhabricatorConfigOption.php
212

✅ 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