mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-08 16:02:40 +01:00
Fix PHP 8.1 "strlen(null)" exception on UIExamples' Bars page
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. Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15441 Differential Revision: https://we.phorge.it/D25272
This commit is contained in:
parent
dd24c94b07
commit
d8d65f3f87
1 changed files with 6 additions and 1 deletions
|
@ -26,6 +26,11 @@ final class PHUISegmentBarSegmentView extends AphrontTagView {
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a Tooltip.
|
||||
* @param string|null $tooltip
|
||||
* @return self
|
||||
*/
|
||||
public function setTooltip($tooltip) {
|
||||
$this->tooltip = $tooltip;
|
||||
return $this;
|
||||
|
@ -55,7 +60,7 @@ final class PHUISegmentBarSegmentView extends AphrontTagView {
|
|||
$left = sprintf('%.2f%%', $left);
|
||||
|
||||
$tooltip = $this->tooltip;
|
||||
if (strlen($tooltip)) {
|
||||
if (phutil_nonempty_string($tooltip)) {
|
||||
Javelin::initBehavior('phabricator-tooltips');
|
||||
|
||||
$sigil = 'has-tooltip';
|
||||
|
|
Loading…
Reference in a new issue