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
F3329795: D25196.1743480138.diff
Mon, Mar 31, 04:02
F3329180: D25196.1743471140.diff
Mon, Mar 31, 01:32
F3328670: D25196.1743460477.diff
Sun, Mar 30, 22:34
F3328399: D25196.1743456281.diff
Sun, Mar 30, 21:24
F3327750: D25196.1743445331.diff
Sun, Mar 30, 18:22
F3324117: D25196.1743395332.diff
Sun, Mar 30, 04:28
F3322838: D25196.1743379336.diff
Sun, Mar 30, 00:02
F3311216: D25196.1743201898.diff
Thu, Mar 27, 22:44

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