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
F3320243: D25194.1743325216.diff
Sat, Mar 29, 09:00
F3319002: D25194.1743296508.diff
Sat, Mar 29, 01:01
F3315142: D25194.1743235832.diff
Fri, Mar 28, 08:10
F3307032: D25194.1743137250.diff
Thu, Mar 27, 04:47
F3306337: D25194.1743127204.diff
Thu, Mar 27, 02:00
F3296350: D25194.1742971647.diff
Tue, Mar 25, 06:47
F3294990: D25194.1742948692.diff
Tue, Mar 25, 00:24
F3294216: D25194.1742930621.diff
Mon, Mar 24, 19:23

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