From 9da15fd7ab7071e3b7361463229abd4e918d9d94 Mon Sep 17 00:00:00 2001 From: epriestley Date: Sat, 9 Jul 2016 06:47:32 -0700 Subject: [PATCH] (stable) By default, do not save queries when executing Conduit "*.search" calls Summary: Fixes T11304. Prior to this change, we did an unnecessary write on every "*.search" call (this write didn't always actually write a row, since we only save //unique// saved queries, but still doesn't do anything useful ever, currently). Instead, change this to not-write by default. We could add an "oh, and also I want you to do a write" option later, which would let us implement something like `arc query-stuff` which says "To see more results, view this URI in your browser: ...". (It's possible to run one of these methods with an existing SavedQuery by using the key, so we still sometimes have a queryKey to return.) Test Plan: Ran `almanac.service.search`, used DarkConsole to verify that no serachengine writes occurred. Reviewers: chad Reviewed By: chad Maniphest Tasks: T11304 Differential Revision: https://secure.phabricator.com/D16263 --- .../search/engine/PhabricatorApplicationSearchEngine.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/applications/search/engine/PhabricatorApplicationSearchEngine.php b/src/applications/search/engine/PhabricatorApplicationSearchEngine.php index 96363ed947..d7268facb3 100644 --- a/src/applications/search/engine/PhabricatorApplicationSearchEngine.php +++ b/src/applications/search/engine/PhabricatorApplicationSearchEngine.php @@ -1160,7 +1160,11 @@ abstract class PhabricatorApplicationSearchEngine extends Phobject { $saved_query->setParameter($field->getKey(), $value); } - $this->saveQuery($saved_query); + // NOTE: Currently, when running an ad-hoc query we never persist it into + // a saved query. We might want to add an option to do this in the future + // (for example, to enable a CLI-to-Web workflow where user can view more + // details about results by following a link), but have no use cases for + // it today. If we do identify a use case, we could save the query here. $query = $this->buildQueryFromSavedQuery($saved_query); $pager = $this->newPagerForSavedQuery($saved_query); @@ -1234,6 +1238,7 @@ abstract class PhabricatorApplicationSearchEngine extends Phobject { 'data' => $data, 'maps' => $method->getQueryMaps($query), 'query' => array( + // This may be `null` if we have not saved the query. 'queryKey' => $saved_query->getQueryKey(), ), 'cursor' => array(