Page MenuHomePhorge

Fix numerous PHP 8.1 "strlen(null)" exceptions trying to create a project
ClosedPublic

Authored by aklapper on Apr 28 2023, 16:45.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Apr 25, 14:57
Unknown Object (File)
Thu, Apr 25, 14:57
Unknown Object (File)
Thu, Apr 25, 14:41
Unknown Object (File)
Thu, Apr 25, 14:31
Unknown Object (File)
Sat, Apr 13, 19:05
Unknown Object (File)
Sat, Apr 13, 19:04
Unknown Object (File)
Sat, Apr 13, 18:41
Unknown Object (File)
Sat, Apr 13, 17:05

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 your phutil_nonempty_string() throws an exception, just
report it to Phorge to evaluate and fix together that specific corner case.

Closes T15286

Test Plan

Applied these five changes and /project/view/1/ finally rendered in web browser.

Diff Detail

Repository
rP Phorge
Branch
T15286 (branched from master)
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 281
Build 281: arc lint + arc unit

Event Timeline

sgtm

src/applications/project/menuitem/PhabricatorProjectManageProfileMenuItem.php
34

✅ The input domain seems correct to me, since it should be a string or null and alien values should be reported.

Some context:

PhabricatorProfileMenuItemConfiguration.php
...
  public function getMenuItemProperty($key, $default = null) {
    return idx($this->menuItemProperties, $key, $default);
  }
...
src/applications/project/menuitem/PhabricatorProjectMembersProfileMenuItem.php
24

✅ The input domain seems correct to me, since it should be a string or null and alien values should be reported. Same as above.

src/applications/project/menuitem/PhabricatorProjectSubprojectsProfileMenuItem.php
32

✅ The input domain seems correct to me, since it should be a string or null and alien values should be reported. Same as above.

src/applications/project/menuitem/PhabricatorProjectWorkboardProfileMenuItem.php
41

✅ The input domain seems correct to me, since it should be a string or null and alien values should be reported. Same as above.

src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
620

✅ It's OK to assume a PHID as string or as NULL (default). Alien values will be reported and this is OK.

This revision is now accepted and ready to land.Apr 29 2023, 08:35