1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 06:42:42 +01:00

Fix PHP 8.1 "strlen(null)" and "array_slice(null)" exceptions which block typeahead completion proposals

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.

`array_slice()` no longer accepts passing `null` as a parameter.
This behavior is deprecated since PHP 8.1. Adding an if clause; not using a
Null Coalescing Operator (PHP 7+) as Phorge currently still supports PHP 5.5.

Closes T15321

Test Plan:
Applied these two changes on top of D25147. Afterwards, typeahead autocompletion
proposal dropdowns for the three fields "Assigned To", "Subscribers", "Tags" got
displayed in web browser.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15321

Differential Revision: https://we.phorge.it/D25170
This commit is contained in:
Andre Klapper 2023-05-01 22:28:57 +02:00
parent dff04ba91d
commit aea1d47379
2 changed files with 6 additions and 2 deletions

View file

@ -39,7 +39,7 @@ final class PhabricatorTypeaheadModularDatasourceController
$parameters = array();
$raw_parameters = $request->getStr('parameters');
if (strlen($raw_parameters)) {
if (phutil_nonempty_string($raw_parameters)) {
try {
$parameters = phutil_json_decode($raw_parameters);
} catch (PhutilJSONParserException $ex) {

View file

@ -207,7 +207,11 @@ abstract class PhabricatorTypeaheadCompositeDatasource
}
protected function sliceResults(array $results) {
$offset = $this->getOffset();
if ($this->getOffset()) {
$offset = $this->getOffset();
} else {
$offset = 0;
}
$limit = $this->getLimit();
if ($offset || $limit) {