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.

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