Differential D25214 Diff 718 src/applications/owners/typeahead/PhabricatorOwnersPackageDatasource.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/owners/typeahead/PhabricatorOwnersPackageDatasource.php
Show All 20 Lines | public function loadResults() { | ||||
$results = array(); | $results = array(); | ||||
$query = id(new PhabricatorOwnersPackageQuery()) | $query = id(new PhabricatorOwnersPackageQuery()) | ||||
->setOrder('name'); | ->setOrder('name'); | ||||
// If the user is querying by monogram explicitly, like "O123", do an ID | // If the user is querying by monogram explicitly, like "O123", do an ID | ||||
// search. Otherwise, do an ngram substring search. | // search. Otherwise, do an ngram substring search. | ||||
if (preg_match('/^[oO]\d+\z/', $raw_query)) { | if ($raw_query && preg_match('/^[oO]\d+\z/', $raw_query)) { | ||||
$id = trim($raw_query, 'oO'); | $id = trim($raw_query, 'oO'); | ||||
valerio.bozzolan: ✅ I verified the above line
The potential pitfall is: the string `"0"` is falsy, but that is… | |||||
$id = (int)$id; | $id = (int)$id; | ||||
$query->withIDs(array($id)); | $query->withIDs(array($id)); | ||||
} else { | } else { | ||||
$query->withNameNgrams($raw_query); | $query->withNameNgrams($raw_query); | ||||
} | } | ||||
$packages = $this->executeQuery($query); | $packages = $this->executeQuery($query); | ||||
foreach ($packages as $package) { | foreach ($packages as $package) { | ||||
Show All 19 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0
✅ I verified the above line
The potential pitfall is: the string "0" is falsy, but that is really intended here.