Page MenuHomePhorge

Fix PHP 8.1 "strlen(null)" exception which blocks blog rendering

Authored by aklapper on May 6 2023, 10:23.
Referenced Files
Unknown Object (File)
Thu, Apr 11, 12:35
Unknown Object (File)
Thu, Apr 11, 07:37
Unknown Object (File)
Wed, Apr 10, 17:36
Unknown Object (File)
Fri, Apr 5, 13:24
Unknown Object (File)
Sun, Mar 31, 12:33
Unknown Object (File)
Sun, Mar 31, 12:33
Unknown Object (File)
Tue, Mar 26, 12:46
Unknown Object (File)
Tue, Mar 26, 11:33



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 T15356

Test Plan

Applied this change change on top of D25194 and /phame/blog/view/1/ rendered in web browser.

Diff Detail

rP Phorge
Lint Not Applicable
Tests Not Applicable

Event Timeline

aklapper requested review of this revision.May 6 2023, 10:23

Thanks for this patch

I tested this patch locally, no implosions.



✅ I verified the above line

The $post_id comes from getURIData() that just returns null or a string.

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

This revision is now accepted and ready to land.May 8 2023, 10:03