Page MenuHomePhorge

Fix PHP 8.1 "strlen(null)" exception rendering dashboard panel with latest tasks when custom text field configured
ClosedPublic

Authored by aklapper on Dec 5 2023, 03:15.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Apr 28, 00:24
Unknown Object (File)
Sat, Apr 27, 16:46
Unknown Object (File)
Wed, Apr 24, 22:46
Unknown Object (File)
Wed, Apr 17, 18:16
Unknown Object (File)
Wed, Apr 17, 06:38
Unknown Object (File)
Apr 6 2024, 18:53
Unknown Object (File)
Apr 6 2024, 08:40
Unknown Object (File)
Apr 6 2024, 06:53

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.

EXCEPTION: (RuntimeException) strlen(): Passing null to parameter #1 ($string) of type string is deprecated at [<arcanist>/src/error/PhutilErrorHandler.php:261]
  #0 <#2> PhutilErrorHandler::handleError(integer, string, string, integer) called at [<phorge>/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldText.php:33]

Closes T15684

Test Plan

After configuring a custom text field and a dashboard panel to query and listed the latest created tasks, access the panel.

Diff Detail

Repository
rP Phorge
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

aklapper requested review of this revision.Dec 5 2023, 03:15

Hmm, I guess the patch should also change line 14 in the same way? I managed to reach that line with the same problem but do not remember the exact steps I performed...

Hmm, I guess the patch should also change line 14 in the same way? I managed to reach that line with the same problem but do not remember the exact steps I performed...

Yes, we can do that also in line 14

To reproduce the crash there, I visited the page

/config/edit/maniphest.custom-field-definitions/

And I've added this custom field with search enabled:

{
  "megalol:favorite-dinosaur": {
    "name": "Favorite Dinosaur",
    "type": "text",
    "search": true
  }
}

I can sticky-accept the change. Feel free to update line 14 and land (no need to re-approve again here).

This revision is now accepted and ready to land.Dec 6 2023, 06:53