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
F3328907: D25140.1743465152.diff
Sun, Mar 30, 23:52
F3328186: D25140.1743451474.diff
Sun, Mar 30, 20:04
F3327512: D25140.1743440639.diff
Sun, Mar 30, 17:03
F3325089: D25140.1743408762.diff
Sun, Mar 30, 08:12
F3323271: D25140.1743383762.diff
Sun, Mar 30, 01:16
F3322165: D25140.1743366538.diff
Sat, Mar 29, 20:28
F3321229: D25140.1743349258.diff
Sat, Mar 29, 15:40
F3320359: D25140.1743328308.diff
Sat, Mar 29, 09:51

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