Page MenuHomePhorge

Fix PHP 8.1 "strlen(null)" exceptions which block rendering page to import ICS calendar file

Authored by aklapper on Sat, May 6, 22:52.
Referenced Files
Unknown Object (File)
Wed, May 31, 06:39
Unknown Object (File)
Wed, May 31, 02:30
Unknown Object (File)
Mon, May 22, 16:01
Unknown Object (File)
Mon, May 22, 12:13
Unknown Object (File)
Sun, May 21, 23:21
Unknown Object (File)
Tue, May 16, 17:02



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 T15362

Test Plan

Applied these two changes and /calendar/import/edit/ correctly rendered the "Create Import" page in the web browser, with the expected error about the missing ICS file (instead of an exception stacktrace).

Diff Detail

rP Phorge
Lint Not Applicable
Tests Not Applicable

Event Timeline

aklapper requested review of this revision.Sat, May 6, 22:52

I tested both values locally with phlog() and using some forms as the test plan suggests.

The $new_value just assumes null, or strings like PHID-FILE-w4n7l42i3gcq5x6rvwcy for a file upload. The $filename is also always a string or null.

The function phutil_nonempty_string() will report any alien type, and that is OK here.

This revision is now accepted and ready to land.Mon, May 8, 20:08