diff --git a/src/applications/search/controller/PhabricatorApplicationSearchController.php b/src/applications/search/controller/PhabricatorApplicationSearchController.php index 6c7d80eafe..cc8bcefff1 100644 --- a/src/applications/search/controller/PhabricatorApplicationSearchController.php +++ b/src/applications/search/controller/PhabricatorApplicationSearchController.php @@ -7,6 +7,7 @@ final class PhabricatorApplicationSearchController private $navigation; private $queryKey; private $preface; + private $activeQuery; public function setPreface($preface) { $this->preface = $preface; @@ -45,6 +46,14 @@ final class PhabricatorApplicationSearchController return $this->searchEngine; } + protected function getActiveQuery() { + if (!$this->activeQuery) { + throw new Exception(pht('There is no active query yet.')); + } + + return $this->activeQuery; + } + protected function validateDelegatingController() { $parent = $this->getDelegatingController(); @@ -158,6 +167,8 @@ final class PhabricatorApplicationSearchController $engine->saveQuery($saved_query); } + $this->activeQuery = $saved_query; + $nav->selectFilter( 'query/'.$saved_query->getQueryKey(), 'query/advanced'); @@ -867,10 +878,8 @@ final class PhabricatorApplicationSearchController $engine = $this->getSearchEngine(); $engine_class = get_class($engine); - $query_key = $this->getQueryKey(); - if (!$query_key) { - $query_key = $engine->getDefaultQueryKey(); - } + + $query_key = $this->getActiveQuery()->getQueryKey(); $can_use = $engine->canUseInPanelContext(); $is_installed = PhabricatorApplication::isClassInstalledForViewer(