Remove PhabricatorPHID::fromObjectName

Summary: Ref T2715. This only ever supported like 10% of object types; get rid of it in favor of the new infra.

Test Plan:
  - Ran `bin/search index D12`; `bin/search index <some valid phid>`, `bin/search index derp`.
  - Turned off Search jump, searched for `D12`.
  - Used `phid.lookup`.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2715

Differential Revision: https://secure.phabricator.com/D6519
This commit is contained in:
epriestley
2013-07-21 13:11:39 -07:00
parent 2ff57f6938
commit 2845d11962
5 changed files with 67 additions and 69 deletions

View File

@@ -220,10 +220,16 @@ final class PhabricatorSearchController
$results = $engine->executeSearch($query);
$results = $pager->sliceResults($results);
// If there are any objects which match the query by name, and we're
// not paging through the results, prefix the results with the named
// objects.
if (!$request->getInt('page')) {
$jump = PhabricatorPHID::fromObjectName($query->getQuery(), $user);
if ($jump) {
array_unshift($results, $jump);
$named = id(new PhabricatorObjectQuery())
->setViewer($user)
->withNames(array($query->getQuery()))
->execute();
if ($named) {
$results = array_merge(array_keys($named), $results);
}
}

View File

@@ -91,18 +91,20 @@ final class PhabricatorSearchManagementIndexWorkflow
}
private function loadPHIDsByNames(array $names) {
$phids = array();
$query = id(new PhabricatorObjectQuery())
->setViewer(PhabricatorUser::getOmnipotentUser())
->withNames($names);
$query->execute();
$objects = $query->getNamedResults();
foreach ($names as $name) {
$phid = PhabricatorPHID::fromObjectName(
$name,
PhabricatorUser::getOmnipotentUser());
if (!$phid) {
if (empty($objects[$name])) {
throw new PhutilArgumentUsageException(
"'{$name}' is not the name of a known object.");
}
$phids[] = $phid;
}
return $phids;
return mpull($objects, 'getPHID');
}
private function loadPHIDsByTypes($type) {