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.

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
Branch
addDashboard (branched from master)
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 353
Build 353: arc lint + arc unit

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