1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-19 16:58:48 +02:00

Fix PHP 8.1 "strlen(null)" exceptions editing existing Dashboard query panel with no query defined

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.

```
ERROR 8192: strlen(): Passing null to parameter #1 ($string) of type string is deprecated at [/var/www/html/phorge/phorge/src/applications/dashboard/editfield/PhabricatorDashboardQueryPanelQueryEditField.php:41]
```

```
ERROR 8192: strlen(): Passing null to parameter #1 ($string) of type string is deprecated at [/var/www/html/phorge/phorge/src/applications/dashboard/editfield/PhabricatorDashboardQueryPanelQueryEditField.php:59]
```

Closes T15791

Test Plan: Successfully create a Dashboard query panel searching for "Diffusion Raw Commits" (which has no Query defined per T15790) and try to edit it afterwards under PHP 8.1 or later.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15791

Differential Revision: https://we.phorge.it/D25596
This commit is contained in:
Andre Klapper 2024-04-18 19:50:03 +02:00
parent 3349c3be17
commit 17b568b94f

View file

@ -38,7 +38,7 @@ final class PhabricatorDashboardQueryPanelQueryEditField
}
}
if (strlen($value) && !$seen) {
if (phutil_nonempty_string($value) && !$seen) {
$name = pht('Custom Query ("%s")', $value);
} else {
$name = pht('(None)');
@ -56,7 +56,7 @@ final class PhabricatorDashboardQueryPanelQueryEditField
'queryID' => $control_id,
'options' => $queries,
'value' => array(
'key' => strlen($value) ? $value : null,
'key' => phutil_nonempty_string($value) ? $value : null,
'name' => $name,
),
));