Page MenuHomePhorge

Fix PHP 8.1 "strlen(null)" exception which blocks rendering a File page when Alt Text was altered

Authored by aklapper on May 4 2023, 12:01.
Referenced Files
Unknown Object (File)
Wed, May 31, 06:35
Unknown Object (File)
Tue, May 23, 04:35
Unknown Object (File)
Mon, May 22, 14:33
Unknown Object (File)
Sun, May 21, 17:27
Unknown Object (File)
Wed, May 17, 20:04
Unknown Object (File)
Mon, May 8, 07:50



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 T15342

Test Plan

Applied these two changes on top of D25186.
Added an Alt Text to a file; page of the File now rendered correctly in web browser.
Removed Alt Text from a file; page of the File now rendered correctly in web browser.

Diff Detail

rP Phorge
Lint Not Applicable
Tests Not Applicable

Event Timeline

aklapper requested review of this revision.May 4 2023, 12:01

Thank you for this patch, again (!!!!!!)

I tested this patch locally, putting a phplog() to monitor $new_value and $old_value and doing an extended fuzzy test and I can confirm their assumed input domain: the assumes just a string or null (default).

The function phutil_nonempty_string() will report any alien type, and that is OK in these cases.

Green light and thanks again



This revision is now accepted and ready to land.May 5 2023, 21:09