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
F3225558: D25184.1742129197.diff
Sat, Mar 15, 12:46
F3222549: D25184.1741927076.diff
Thu, Mar 13, 04:37
F3220839: D25184.1741813165.diff
Tue, Mar 11, 20:59
F3011339: D25184.1740660409.diff
Wed, Feb 26, 12:46
F3011338: D25184.1740660407.diff
Wed, Feb 26, 12:46
F3011337: D25184.1740660320.diff
Wed, Feb 26, 12:45
F3011336: D25184.1740660256.diff
Wed, Feb 26, 12:44
F2963261: D25184.1739203766.diff
Feb 9 2025, 16:09

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