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
F2203496: D25168.1716589052.diff
Thu, May 23, 22:17
F2203389: D25168.1716573050.diff
Thu, May 23, 17:50
Unknown Object (File)
Sun, May 5, 20:34
Unknown Object (File)
Sun, May 5, 19:06
Unknown Object (File)
Thu, May 2, 18:55
Unknown Object (File)
Thu, Apr 25, 22:06
Unknown Object (File)
Thu, Apr 25, 16:55
Unknown Object (File)
Thu, Apr 25, 16: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 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
Lint
Lint Not Applicable
Unit
Tests Not Applicable

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).