1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-20 12:30:56 +01:00

Only link symbols if there might be any

Summary:
fixes T8260. Only turn on symbol links if:
- The repository has any configuration about symbols, or
- There actually are symbols in the repository.

Test Plan: Look at revisions and files in various states of configurations and having symbols.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: joshuaspence, Korvin, epriestley

Maniphest Tasks: T8260

Differential Revision: https://secure.phabricator.com/D12946
This commit is contained in:
Aviv Eyal 2015-05-21 08:25:34 -07:00 committed by epriestley
parent a04af2a9ee
commit f21972a01f
3 changed files with 51 additions and 15 deletions

View file

@ -261,12 +261,11 @@ final class DifferentialRevisionViewController extends DifferentialController {
$repository = $revision->getRepository(); $repository = $revision->getRepository();
if ($repository) { if ($repository) {
list($symbol_indexes, $repository_phids) = $this->buildSymbolIndexes( $symbol_indexes = $this->buildSymbolIndexes(
$repository, $repository,
$visible_changesets); $visible_changesets);
} else { } else {
$symbol_indexes = array(); $symbol_indexes = array();
$repository_phids = null;
} }
$revision_detail->setActions($actions); $revision_detail->setActions($actions);
@ -306,15 +305,6 @@ final class DifferentialRevisionViewController extends DifferentialController {
), ),
$comment_view); $comment_view);
if ($repository) {
Javelin::initBehavior(
'repository-crossreference',
array(
'section' => $wrap_id,
'repositories' => $repository_phids,
));
}
$changeset_view = new DifferentialChangesetListView(); $changeset_view = new DifferentialChangesetListView();
$changeset_view->setChangesets($changesets); $changeset_view->setChangesets($changesets);
$changeset_view->setVisibleChangesets($visible_changesets); $changeset_view->setVisibleChangesets($visible_changesets);
@ -758,11 +748,22 @@ final class DifferentialRevisionViewController extends DifferentialController {
$langs = $repository->getSymbolLanguages(); $langs = $repository->getSymbolLanguages();
$langs = nonempty($langs, array()); $langs = nonempty($langs, array());
$sources = $repository->getSymbolSources();
$sources = nonempty($sources, array());
$symbol_indexes = array(); $symbol_indexes = array();
if ($langs && $sources) {
$have_symbols = id(new DiffusionSymbolQuery())
->existsSymbolsInRepository($repository->getPHID());
if (!$have_symbols) {
return $symbol_indexes;
}
}
$repository_phids = array_merge( $repository_phids = array_merge(
array($repository->getPHID()), array($repository->getPHID()),
nonempty($repository->getSymbolSources(), array())); $sources);
$indexed_langs = array_fill_keys($langs, true); $indexed_langs = array_fill_keys($langs, true);
foreach ($visible_changesets as $key => $changeset) { foreach ($visible_changesets as $key => $changeset) {
@ -775,7 +776,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
} }
} }
return array($symbol_indexes, $repository_phids); return $symbol_indexes;
} }
private function loadOtherRevisions( private function loadOtherRevisions(

View file

@ -267,13 +267,28 @@ final class DiffusionBrowseFileController extends DiffusionBrowseController {
$id = celerity_generate_unique_node_id(); $id = celerity_generate_unique_node_id();
$repo = $drequest->getRepository(); $repo = $drequest->getRepository();
$symbol_repos = $repo->getSymbolSources(); $symbol_repos = nonempty($repo->getSymbolSources(), array());
$symbol_repos[] = $repo; $symbol_repos[] = $repo;
$lang = last(explode('.', $drequest->getPath())); $lang = last(explode('.', $drequest->getPath()));
$repo_languages = $repo->getSymbolLanguages(); $repo_languages = $repo->getSymbolLanguages();
$repo_languages = nonempty($repo_languages, array());
$repo_languages = array_fill_keys($repo_languages, true); $repo_languages = array_fill_keys($repo_languages, true);
if (empty($repo_languages) || isset($repo_languages[$lang])) {
$needs_symbols = true;
if ($repo_languages && $symbol_repos) {
$have_symbols = id(new DiffusionSymbolQuery())
->existsSymbolsInRepository($repo->getPHID());
if (!$have_symbols) {
$needs_symbols = false;
}
}
if ($needs_symbols && $repo_languages) {
$needs_symbols = isset($repo_languages[$lang]);
}
if ($needs_symbols) {
Javelin::initBehavior( Javelin::initBehavior(
'repository-crossreference', 'repository-crossreference',
array( array(

View file

@ -113,6 +113,26 @@ final class DiffusionSymbolQuery extends PhabricatorOffsetPagedQuery {
} }
/* -( Specialized Query )-------------------------------------------------- */
public function existsSymbolsInRepository($repository_phid) {
$this
->withRepositoryPHIDs(array($repository_phid))
->setLimit(1);
$symbol = new PhabricatorRepositorySymbol();
$conn_r = $symbol->establishConnection('r');
$data = queryfx_all(
$conn_r,
'SELECT * FROM %T %Q %Q',
$symbol->getTableName(),
$this->buildWhereClause($conn_r),
$this->buildLimitClause($conn_r));
return (!empty($data));
}
/* -( Executing the Query )------------------------------------------------ */ /* -( Executing the Query )------------------------------------------------ */