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.

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