diff --git a/src/applications/differential/controller/DifferentialRevisionViewController.php b/src/applications/differential/controller/DifferentialRevisionViewController.php index 849ef056aa..cdefdd65d7 100644 --- a/src/applications/differential/controller/DifferentialRevisionViewController.php +++ b/src/applications/differential/controller/DifferentialRevisionViewController.php @@ -261,12 +261,11 @@ final class DifferentialRevisionViewController extends DifferentialController { $repository = $revision->getRepository(); if ($repository) { - list($symbol_indexes, $repository_phids) = $this->buildSymbolIndexes( + $symbol_indexes = $this->buildSymbolIndexes( $repository, $visible_changesets); } else { $symbol_indexes = array(); - $repository_phids = null; } $revision_detail->setActions($actions); @@ -306,15 +305,6 @@ final class DifferentialRevisionViewController extends DifferentialController { ), $comment_view); - if ($repository) { - Javelin::initBehavior( - 'repository-crossreference', - array( - 'section' => $wrap_id, - 'repositories' => $repository_phids, - )); - } - $changeset_view = new DifferentialChangesetListView(); $changeset_view->setChangesets($changesets); $changeset_view->setVisibleChangesets($visible_changesets); @@ -758,11 +748,22 @@ final class DifferentialRevisionViewController extends DifferentialController { $langs = $repository->getSymbolLanguages(); $langs = nonempty($langs, array()); + $sources = $repository->getSymbolSources(); + $sources = nonempty($sources, 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( array($repository->getPHID()), - nonempty($repository->getSymbolSources(), array())); + $sources); $indexed_langs = array_fill_keys($langs, true); 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( diff --git a/src/applications/diffusion/controller/DiffusionBrowseFileController.php b/src/applications/diffusion/controller/DiffusionBrowseFileController.php index 731906943c..6fcda177a5 100644 --- a/src/applications/diffusion/controller/DiffusionBrowseFileController.php +++ b/src/applications/diffusion/controller/DiffusionBrowseFileController.php @@ -267,13 +267,28 @@ final class DiffusionBrowseFileController extends DiffusionBrowseController { $id = celerity_generate_unique_node_id(); $repo = $drequest->getRepository(); - $symbol_repos = $repo->getSymbolSources(); + $symbol_repos = nonempty($repo->getSymbolSources(), array()); $symbol_repos[] = $repo; $lang = last(explode('.', $drequest->getPath())); $repo_languages = $repo->getSymbolLanguages(); + $repo_languages = nonempty($repo_languages, array()); $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( 'repository-crossreference', array( diff --git a/src/applications/diffusion/query/DiffusionSymbolQuery.php b/src/applications/diffusion/query/DiffusionSymbolQuery.php index 6017c45f6f..0e08b7b32d 100644 --- a/src/applications/diffusion/query/DiffusionSymbolQuery.php +++ b/src/applications/diffusion/query/DiffusionSymbolQuery.php @@ -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 )------------------------------------------------ */