1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 14:52:41 +01:00

Fix an export bug where queries specified in the URI ("?param=value") were ignored when filtering the result set

Summary:
Depends on D18968. Ref T13049. Currently, if you visit `/query/?param=value`, there is no `queryKey` for the page but we build a query later on.

Right now, we incorrectly link to `/query/all/export/` in this case (and export too many results), but we should actually link to `/query/<constructed query key>/export/` to export only the desired/previewed results.

Swap the logic around a little bit so we look at the query we're actually executing, not the original URI, to figure out the query key we should use when building the link.

Test Plan: Visited a `/?param=value` page, exported data, got a subset of the full data instead of everything.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13049

Differential Revision: https://secure.phabricator.com/D18969
This commit is contained in:
epriestley 2018-01-30 08:03:29 -08:00
parent 5b22412f24
commit 0d5379ee17

View file

@ -7,6 +7,7 @@ final class PhabricatorApplicationSearchController
private $navigation; private $navigation;
private $queryKey; private $queryKey;
private $preface; private $preface;
private $activeQuery;
public function setPreface($preface) { public function setPreface($preface) {
$this->preface = $preface; $this->preface = $preface;
@ -45,6 +46,14 @@ final class PhabricatorApplicationSearchController
return $this->searchEngine; 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() { protected function validateDelegatingController() {
$parent = $this->getDelegatingController(); $parent = $this->getDelegatingController();
@ -158,6 +167,8 @@ final class PhabricatorApplicationSearchController
$engine->saveQuery($saved_query); $engine->saveQuery($saved_query);
} }
$this->activeQuery = $saved_query;
$nav->selectFilter( $nav->selectFilter(
'query/'.$saved_query->getQueryKey(), 'query/'.$saved_query->getQueryKey(),
'query/advanced'); 'query/advanced');
@ -867,10 +878,8 @@ final class PhabricatorApplicationSearchController
$engine = $this->getSearchEngine(); $engine = $this->getSearchEngine();
$engine_class = get_class($engine); $engine_class = get_class($engine);
$query_key = $this->getQueryKey();
if (!$query_key) { $query_key = $this->getActiveQuery()->getQueryKey();
$query_key = $engine->getDefaultQueryKey();
}
$can_use = $engine->canUseInPanelContext(); $can_use = $engine->canUseInPanelContext();
$is_installed = PhabricatorApplication::isClassInstalledForViewer( $is_installed = PhabricatorApplication::isClassInstalledForViewer(