mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42:41 +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:
parent
2b0b9a1573
commit
e2e9aed4fa
3 changed files with 18 additions and 4 deletions
|
@ -70,15 +70,21 @@ final class ConduitAPI_diffusion_findsymbols_Method
|
||||||
|
|
||||||
$results = $query->execute();
|
$results = $query->execute();
|
||||||
|
|
||||||
|
|
||||||
$response = array();
|
$response = array();
|
||||||
foreach ($results as $result) {
|
foreach ($results as $result) {
|
||||||
|
$uri = $result->getURI();
|
||||||
|
if ($uri) {
|
||||||
|
$uri = PhabricatorEnv::getProductionURI($uri);
|
||||||
|
}
|
||||||
|
|
||||||
$response[] = array(
|
$response[] = array(
|
||||||
'name' => $result->getSymbolName(),
|
'name' => $result->getSymbolName(),
|
||||||
'type' => $result->getSymbolType(),
|
'type' => $result->getSymbolType(),
|
||||||
'language' => $result->getSymbolLanguage(),
|
'language' => $result->getSymbolLanguage(),
|
||||||
'path' => $result->getPath(),
|
'path' => $result->getPath(),
|
||||||
'line' => $result->getLineNumber(),
|
'line' => $result->getLineNumber(),
|
||||||
'uri' => PhabricatorEnv::getProductionURI($result->getURI()),
|
'uri' => $uri,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,13 @@ final class PhabricatorRepositorySymbol extends PhabricatorRepositoryDAO {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getURI() {
|
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(
|
$request = DiffusionRequest::newFromDictionary(
|
||||||
array(
|
array(
|
||||||
'repository' => $this->getRepository(),
|
'repository' => $this->getRepository(),
|
||||||
|
|
|
@ -240,16 +240,17 @@ final class PhabricatorIRCObjectNameHandler extends PhabricatorIRCHandler {
|
||||||
'name' => $symbol,
|
'name' => $symbol,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
$default_uri = $this->getURI('/diffusion/symbol/'.$symbol.'/');
|
||||||
|
|
||||||
if (count($results) > 1) {
|
if (count($results) > 1) {
|
||||||
$uri = $this->getURI('/diffusion/symbol/'.$symbol.'/');
|
$response = "Multiple symbols named '{$symbol}': {$default_uri}";
|
||||||
$response = "Multiple symbols named '{$symbol}': {$uri}";
|
|
||||||
} else if (count($results) == 1) {
|
} else if (count($results) == 1) {
|
||||||
$result = head($results);
|
$result = head($results);
|
||||||
$response =
|
$response =
|
||||||
$result['type'].' '.
|
$result['type'].' '.
|
||||||
$result['name'].' '.
|
$result['name'].' '.
|
||||||
'('.$result['language'].'): '.
|
'('.$result['language'].'): '.
|
||||||
$result['uri'];
|
nonempty($result['uri'], $default_uri);
|
||||||
} else {
|
} else {
|
||||||
$response = "No symbol '{$symbol}' found anywhere.";
|
$response = "No symbol '{$symbol}' found anywhere.";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue