Page MenuHomePhorge

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

Authored by aklapper on May 4 2023, 10:55.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Mar 27, 17:32
Unknown Object (File)
Feb 25 2024, 07:36
Unknown Object (File)
Feb 25 2024, 07:36
Unknown Object (File)
Feb 25 2024, 06:54
Unknown Object (File)
Feb 25 2024, 06:46
Unknown Object (File)
Feb 19 2024, 10:42
Unknown Object (File)
Feb 17 2024, 12:39
Unknown Object (File)
Feb 17 2024, 12:39

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.May 4 2023, 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.May 5 2023, 19:50