mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 06:42:42 +01:00
Fix PHP 8.1 "strlen(null)" exception rendering dashboard panel with latest tasks when custom int field configured
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/infrastructure/customfield/standard/PhabricatorStandardCustomFieldInt.php:56] ``` Closes T15685 Test Plan: After configuring a custom `int` field and a dashboard panel to query and listed the latest created tasks, access the panel and check the PHP error log. Reviewers: O1 Blessed Committers, speck, valerio.bozzolan Reviewed By: O1 Blessed Committers, speck, valerio.bozzolan Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15685 Differential Revision: https://we.phorge.it/D25489
This commit is contained in:
parent
821708414e
commit
052b5f41c7
1 changed files with 5 additions and 5 deletions
|
@ -11,7 +11,7 @@ final class PhabricatorStandardCustomFieldInt
|
||||||
$indexes = array();
|
$indexes = array();
|
||||||
|
|
||||||
$value = $this->getFieldValue();
|
$value = $this->getFieldValue();
|
||||||
if (strlen($value)) {
|
if (phutil_nonempty_scalar($value)) {
|
||||||
$indexes[] = $this->newNumericIndex((int)$value);
|
$indexes[] = $this->newNumericIndex((int)$value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ final class PhabricatorStandardCustomFieldInt
|
||||||
PhabricatorCursorPagedPolicyAwareQuery $query,
|
PhabricatorCursorPagedPolicyAwareQuery $query,
|
||||||
$value) {
|
$value) {
|
||||||
|
|
||||||
if (strlen($value)) {
|
if (phutil_nonempty_scalar($value)) {
|
||||||
$query->withApplicationSearchContainsConstraint(
|
$query->withApplicationSearchContainsConstraint(
|
||||||
$this->newNumericIndex(null),
|
$this->newNumericIndex(null),
|
||||||
$value);
|
$value);
|
||||||
|
@ -84,7 +84,7 @@ final class PhabricatorStandardCustomFieldInt
|
||||||
|
|
||||||
foreach ($xactions as $xaction) {
|
foreach ($xactions as $xaction) {
|
||||||
$value = $xaction->getNewValue();
|
$value = $xaction->getNewValue();
|
||||||
if (strlen($value)) {
|
if (phutil_nonempty_scalar($value)) {
|
||||||
if (!preg_match('/^-?\d+/', $value)) {
|
if (!preg_match('/^-?\d+/', $value)) {
|
||||||
$errors[] = new PhabricatorApplicationTransactionValidationError(
|
$errors[] = new PhabricatorApplicationTransactionValidationError(
|
||||||
$type,
|
$type,
|
||||||
|
@ -104,9 +104,9 @@ final class PhabricatorStandardCustomFieldInt
|
||||||
|
|
||||||
$old = $xaction->getOldValue();
|
$old = $xaction->getOldValue();
|
||||||
$new = $xaction->getNewValue();
|
$new = $xaction->getNewValue();
|
||||||
if (!strlen($old) && strlen($new)) {
|
if (!phutil_nonempty_scalar($old) && phutil_nonempty_scalar($new)) {
|
||||||
return true;
|
return true;
|
||||||
} else if (strlen($old) && !strlen($new)) {
|
} else if (phutil_nonempty_scalar($old) && !phutil_nonempty_scalar($new)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return ((int)$old !== (int)$new);
|
return ((int)$old !== (int)$new);
|
||||||
|
|
Loading…
Reference in a new issue