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
Unknown Object (File)
Fri, Apr 12, 11:50
Unknown Object (File)
Thu, Apr 11, 12:01
Unknown Object (File)
Thu, Apr 11, 02:28
Unknown Object (File)
Thu, Apr 11, 02:17
Unknown Object (File)
Fri, Apr 5, 22:32
Unknown Object (File)
Sun, Mar 31, 12:33
Unknown Object (File)
Sun, Mar 31, 12:33
Unknown Object (File)
Sat, Mar 30, 03:42

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