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

Fix symbol handling in symbol query and IRC "Where is x?" handler

Summary: If a symbol's project has no linked repository, we currently explode. Instead, decline to generate a URI and fall back gracefully.

Test Plan: https://secure.phabricator.com/chatlog/channel/%23phabricator/?at=22345

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T1465

Differential Revision: https://secure.phabricator.com/D2948
This commit is contained in:
epriestley 2012-07-09 17:51:42 -07:00
parent 2b0b9a1573
commit e2e9aed4fa
3 changed files with 18 additions and 4 deletions

View file

@ -70,15 +70,21 @@ final class ConduitAPI_diffusion_findsymbols_Method
$results = $query->execute();
$response = array();
foreach ($results as $result) {
$uri = $result->getURI();
if ($uri) {
$uri = PhabricatorEnv::getProductionURI($uri);
}
$response[] = array(
'name' => $result->getSymbolName(),
'type' => $result->getSymbolType(),
'language' => $result->getSymbolLanguage(),
'path' => $result->getPath(),
'line' => $result->getLineNumber(),
'uri' => PhabricatorEnv::getProductionURI($result->getURI()),
'uri' => $uri,
);
}

View file

@ -45,6 +45,13 @@ final class PhabricatorRepositorySymbol extends PhabricatorRepositoryDAO {
}
public function getURI() {
if (!$this->repository) {
// This symbol is in the index, but we don't know which Repository it's
// part of. Usually this means the Arcanist Project hasn't been linked
// to a Repository. We can't generate a URI, so just fail.
return null;
}
$request = DiffusionRequest::newFromDictionary(
array(
'repository' => $this->getRepository(),

View file

@ -240,16 +240,17 @@ final class PhabricatorIRCObjectNameHandler extends PhabricatorIRCHandler {
'name' => $symbol,
));
$default_uri = $this->getURI('/diffusion/symbol/'.$symbol.'/');
if (count($results) > 1) {
$uri = $this->getURI('/diffusion/symbol/'.$symbol.'/');
$response = "Multiple symbols named '{$symbol}': {$uri}";
$response = "Multiple symbols named '{$symbol}': {$default_uri}";
} else if (count($results) == 1) {
$result = head($results);
$response =
$result['type'].' '.
$result['name'].' '.
'('.$result['language'].'): '.
$result['uri'];
nonempty($result['uri'], $default_uri);
} else {
$response = "No symbol '{$symbol}' found anywhere.";
}