Page MenuHomePhorge

Fix PHP 8.1 "strlen(null)" exception which blocks rendering user's Edit Profile page
ClosedPublic

Authored by aklapper on May 1 2023, 15:09.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Apr 11, 18:51
Unknown Object (File)
Thu, Apr 11, 07:44
Unknown Object (File)
Thu, Apr 11, 07:28
Unknown Object (File)
Thu, Apr 11, 05:50
Unknown Object (File)
Sat, Apr 6, 08:59
Unknown Object (File)
Sun, Mar 31, 12:33
Unknown Object (File)
Sun, Mar 31, 12:33
Unknown Object (File)
Tue, Mar 26, 12: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 phutil_nonempty_string() throws an exception in your
instance, report it to Phorge to evaluate and fix that specific corner case.

Closes T15319

Test Plan

Applied this change (on top of D25147, D25153, D25167) and
/people/editprofile/userid/ finally rendered in web browser.

Diff Detail

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

Event Timeline

aklapper requested review of this revision.May 1 2023, 15:09

Thanks for this

✅ I tested this locally (it was not so easy) with and without custom fields with and without instructions

With and without this:

http://phorge.localhost/config/edit/user.custom-field-definitions/

{
  "mycompany:userNoses": {
    "name": "Estimated Noses",
    "type": "int",
    "instructions": "Estimated //number of noses(( this user **will take**."
  }
}

So it seems the valid input domain of $instructions should be just null or a string.

The phutil_nonempty_string() will report any alien type, and that is OK.

sgtm

This revision is now accepted and ready to land.May 1 2023, 19:37

(Interestingly, it seems that in Maniphest it's not possible to set instructions in their custom fields.definition. Unclear to me if that is a feature or a bug in Maniphest, but unrelated to this).