mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +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:
parent
dff04ba91d
commit
aea1d47379
2 changed files with 6 additions and 2 deletions
|
@ -39,7 +39,7 @@ final class PhabricatorTypeaheadModularDatasourceController
|
||||||
$parameters = array();
|
$parameters = array();
|
||||||
|
|
||||||
$raw_parameters = $request->getStr('parameters');
|
$raw_parameters = $request->getStr('parameters');
|
||||||
if (strlen($raw_parameters)) {
|
if (phutil_nonempty_string($raw_parameters)) {
|
||||||
try {
|
try {
|
||||||
$parameters = phutil_json_decode($raw_parameters);
|
$parameters = phutil_json_decode($raw_parameters);
|
||||||
} catch (PhutilJSONParserException $ex) {
|
} catch (PhutilJSONParserException $ex) {
|
||||||
|
|
|
@ -207,7 +207,11 @@ abstract class PhabricatorTypeaheadCompositeDatasource
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function sliceResults(array $results) {
|
protected function sliceResults(array $results) {
|
||||||
|
if ($this->getOffset()) {
|
||||||
$offset = $this->getOffset();
|
$offset = $this->getOffset();
|
||||||
|
} else {
|
||||||
|
$offset = 0;
|
||||||
|
}
|
||||||
$limit = $this->getLimit();
|
$limit = $this->getLimit();
|
||||||
|
|
||||||
if ($offset || $limit) {
|
if ($offset || $limit) {
|
||||||
|
|
Loading…
Reference in a new issue