Page MenuHomePhorge

Fix PHP 8.1 "strlen(null)" exception on UIExamples' Bars page
ClosedPublic

Authored by aklapper on Jun 2 2023, 19:20.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Apr 22, 05:18
Unknown Object (File)
Sat, Apr 13, 01:33
Unknown Object (File)
Sun, Apr 7, 09:54
Unknown Object (File)
Mon, Apr 1, 01:57
Unknown Object (File)
Sun, Mar 31, 03:09
Unknown Object (File)
Thu, Mar 28, 11:00
Unknown Object (File)
Wed, Mar 27, 17:02
Unknown Object (File)
Mar 14 2024, 23:58

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]
arcanist(head=master, ref.master=b325304b6e52), phorge(head=uiExamples, ref.master=dd24c94b0741, ref.uiExamples=dd24c94b0741)
  #0 <#2> PhutilErrorHandler::handleError(integer, string, string, integer) called at [<phorge>/src/view/phui/PHUISegmentBarSegmentView.php:58]

Closes T15441

Test Plan

After applying this change, going to /uiexample/view/PhabricatorAphrontBarUIExample/,"Bars (PhabricatorAphrontBarUIExample)" renders with beautiful colors.

To see that page, enable prototypes with:

./bin/config set phabricator.show-prototypes true

Also try to create a Milestone on a Project, with the Config maniphest.points enabled, and try to create some Tasks with different points. Visit its Workboard to see the bar that still works with a useful tooltip.

Diff Detail

Repository
rP Phorge
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

aklapper requested review of this revision.Jun 2 2023, 19:20

Thanks again for this patch

✅ I tried adopting $tooltip = phutil_tag('h1', array(),"ASD"); and it has no sense: the tooltip is just a string.

Moreover, the only known usage seems the file PhabricatorProjectPointsProfileMenuItem so I tried to enable the Config maniphest.points, create a Milestone, and create some Tasks Opened / Resolved and With / Without points, and the bar still works.

sgtm

This revision is now accepted and ready to land.Jun 3 2023, 09:40

Hoping to be useful, add minor PHPDoc