mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
Fix PHP 8.1 null parameter exceptions which block rendering the "Browse Projects" overlay dialog
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. Similarly, passing `null` to the `$haystack` parameter of `strpos()` is deprecated in PHP 8.1. Similarly, passing `null` to the `$string` parameter of `ltrim()` is deprecated in PHP 8.1. Closes part of T15335 Test Plan: Applied these four changes in Phorge (plus the one change in D25180 in Arcanist) and the `Browse Projects` overlay dialog finally rendered in web browser and listed existing projects. Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15335 Differential Revision: https://we.phorge.it/D25179
This commit is contained in:
parent
17ebf3a11f
commit
524dc83b4e
3 changed files with 10 additions and 4 deletions
|
@ -21,7 +21,9 @@ final class PhabricatorProjectDatasource
|
|||
$raw_query = $this->getRawQuery();
|
||||
|
||||
// Allow users to type "#qa" or "qa" to find "Quality Assurance".
|
||||
$raw_query = ltrim($raw_query, '#');
|
||||
if ($raw_query !== null) {
|
||||
$raw_query = ltrim($raw_query, '#');
|
||||
}
|
||||
$tokens = self::tokenizeString($raw_query);
|
||||
|
||||
$query = id(new PhabricatorProjectQuery())
|
||||
|
@ -142,7 +144,7 @@ final class PhabricatorProjectDatasource
|
|||
$proj_result->addAttribute($proj->getDisplayIconName());
|
||||
|
||||
$description = idx($descriptions, $phid);
|
||||
if (strlen($description)) {
|
||||
if (phutil_nonempty_string($description)) {
|
||||
$summary = PhabricatorMarkupEngine::summarizeSentence($description);
|
||||
$proj_result->addAttribute($summary);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ abstract class PhabricatorTypeaheadCompositeDatasource
|
|||
|
||||
// We only need to do a prefix phase query if there's an actual query
|
||||
// string. If the user didn't type anything, nothing can possibly match it.
|
||||
if (strlen($this->getRawQuery())) {
|
||||
if (phutil_nonempty_string($this->getRawQuery())) {
|
||||
$phases[] = self::PHASE_PREFIX;
|
||||
}
|
||||
|
||||
|
|
|
@ -464,7 +464,11 @@ abstract class PhabricatorTypeaheadDatasource extends Phobject {
|
|||
// We're looking for a "(" so that a string like "members(q" is identified
|
||||
// and parsed as a function call. This allows us to start generating
|
||||
// results immediately, before the user fully types out "members(quack)".
|
||||
return (strpos($token, '(') !== false);
|
||||
if ($token) {
|
||||
return (strpos($token, '(') !== false);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue