Page MenuHomePhorge

Fix PHP 8.1 "strlen(null)" exceptions which block adding Dashboard to Project Menu
ClosedPublic

Authored by aklapper on Thu, May 4, 10:55.
Tags
None
Referenced Files
Unknown Object (File)
Wed, May 31, 06:35
Unknown Object (File)
Mon, May 22, 04:05
Unknown Object (File)
Sun, May 21, 17:43
Unknown Object (File)
Sun, May 21, 13:00
Unknown Object (File)
Wed, May 17, 06:55

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 T15339

Test Plan

Applied these four changes and /dashboard/install/1/project/ finally 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.Thu, May 4, 10:55

Thanks

Tested this patch locally, no nuclear implosions, I was able to attach a Dashboard to a Project.

Green light from me

yesyes

src/applications/dashboard/install/PhabricatorDashboardObjectInstallWorkflow.php
20

✅ I verified the above line

The input string is supposed to be a string, or null.

The function phutil_nonempty_string() will report alien values, and that is OK.

24

✅ Same as above

Also note that Aphront#getStr() always return a string, or null.

29

✅ Same as above

Note that getMode() is populated from $request->getURIData('modeKey') that should return a string and defaults to null.

32

✅ Note that ctype_digit() is supposed to accept a string

77

✅ Same as above

This revision is now accepted and ready to land.Fri, May 5, 19:50