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)
Tue, Mar 26, 12:46
Unknown Object (File)
Tue, Mar 26, 11:32
Unknown Object (File)
Thu, Mar 14, 23:08
Unknown Object (File)
Thu, Mar 14, 01:47
Unknown Object (File)
Wed, Mar 13, 13:13
Unknown Object (File)
Feb 25 2024, 07:37
Unknown Object (File)
Feb 25 2024, 07:36
Unknown Object (File)
Feb 25 2024, 06:54

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