Page MenuHomePhorge

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

Authored by aklapper on May 6 2023, 10:23.
Tags
None
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

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 T15356

Test Plan

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

Diff Detail

Repository
rP Phorge
Branch
liveBlog (branched from master)
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 366
Build 366: arc lint + arc unit

Event Timeline

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

Thanks for this patch

I tested this patch locally, no implosions.

sgtm

src/applications/phame/controller/PhameLiveController.php
90

✅ 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