Page MenuHomePhorge

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

Authored by aklapper on May 6 2023, 10:11.
Tags
None
Referenced Files
F2993214: D25194.1740276674.diff
Sat, Feb 22, 02:11
F2993213: D25194.1740276673.diff
Sat, Feb 22, 02:11
F2993173: D25194.1740274586.diff
Sat, Feb 22, 01:36
F2993118: D25194.1740272193.diff
Sat, Feb 22, 00:56
F2982315: D25194.1739950037.diff
Tue, Feb 18, 07:27
F2962393: D25194.1739179562.diff
Sun, Feb 9, 09:26
F2945897: D25194.1738371746.diff
Fri, Jan 31, 01:02
F2945704: D25194.1738350531.diff
Thu, Jan 30, 19:08

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 T15355

Test Plan

Applied this change and /phame/blog/manage/3/ correctly 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:11

Tested locally, verified that the domain is never a PhutilURI. No implosions.

Thanks

sgtm

src/applications/phame/storage/PhameBlog.php
172

✅ I verified the above line

The variable comes from the string input field "Full Domain URI" in the page /phame/blog/edit/<number>/ and always is null or a string and never an object.

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:13