@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+5 -5
+5 -5
src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldInt.php
··· 11 11 $indexes = array(); 12 12 13 13 $value = $this->getFieldValue(); 14 - if (strlen($value)) { 14 + if (phutil_nonempty_scalar($value)) { 15 15 $indexes[] = $this->newNumericIndex((int)$value); 16 16 } 17 17 ··· 53 53 PhabricatorCursorPagedPolicyAwareQuery $query, 54 54 $value) { 55 55 56 - if (strlen($value)) { 56 + if (phutil_nonempty_scalar($value)) { 57 57 $query->withApplicationSearchContainsConstraint( 58 58 $this->newNumericIndex(null), 59 59 $value); ··· 84 84 85 85 foreach ($xactions as $xaction) { 86 86 $value = $xaction->getNewValue(); 87 - if (strlen($value)) { 87 + if (phutil_nonempty_scalar($value)) { 88 88 if (!preg_match('/^-?\d+/', $value)) { 89 89 $errors[] = new PhabricatorApplicationTransactionValidationError( 90 90 $type, ··· 104 104 105 105 $old = $xaction->getOldValue(); 106 106 $new = $xaction->getNewValue(); 107 - if (!strlen($old) && strlen($new)) { 107 + if (!phutil_nonempty_scalar($old) && phutil_nonempty_scalar($new)) { 108 108 return true; 109 - } else if (strlen($old) && !strlen($new)) { 109 + } else if (phutil_nonempty_scalar($old) && !phutil_nonempty_scalar($new)) { 110 110 return true; 111 111 } else { 112 112 return ((int)$old !== (int)$new);