Page MenuHomePhorge

Fix PHP 8.1 "strlen(null)" exception which blocks creating a blog post
ClosedPublic

Authored by aklapper on May 6 2023, 10:34.
Tags
None
Referenced Files
F2963538: D25196.1739215424.diff
Sun, Feb 9, 19:23
F2963270: D25196.1739203797.diff
Sun, Feb 9, 16:09
F2962395: D25196.1739179574.diff
Sun, Feb 9, 09:26
F2941260: D25196.1738105848.diff
Mon, Jan 27, 23:10
F2941259: D25196.1738105847.diff
Mon, Jan 27, 23:10
F2936738: D25196.1737938227.diff
Sun, Jan 26, 00:37
F2936683: D25196.1737935567.diff
Sat, Jan 25, 23:52
F2888597: D25196.1737188655.diff
Jan 17 2025, 08:24

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 T15357

Test Plan

Applied this change and created blog post at /phame/post/view/3/blogpost/ 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 6 2023, 10:34

Tested also this one, thanks

No implosions

sgtm

src/applications/phame/storage/PhamePost.php
70–72

✅ I verified the above line

The line was split so to make the linter happy.

I verified that $blog->getDomain() is never a PhutilURI but always is null or a string provided by the user.

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

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