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.

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
Lint
Lint Not Applicable
Unit
Tests Not Applicable

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