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
F3311216: D25196.1743201898.diff
Thu, Mar 27, 22:44
F3310245: D25196.1743193842.diff
Thu, Mar 27, 20:30
F3306525: D25196.1743129466.diff
Thu, Mar 27, 02:37
F3285554: D25196.1742804024.diff
Sun, Mar 23, 08:13
F3283602: D25196.1742755485.diff
Sat, Mar 22, 18:44
F3280463: D25196.1742651792.diff
Fri, Mar 21, 13:56
F3271202: D25196.1742549370.diff
Thu, Mar 20, 09:29
F3248160: D25196.1742239870.diff
Sun, Mar 16, 19:31

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
Branch
createBlogpost (branched from master)
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 367
Build 367: arc lint + arc unit

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–71

✅ 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