@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

After saving a custom query, redirect to its results page

Summary:
Ref T2625. Currently, after saving a query the user is redirected to "/search/", which isn't especially useful. Instead, redirect them back into the application they came from and to the query results page.

Also, query hashes may contain ".", which does not match `\w`. Use `[^/]` instead.

Test Plan: Saved some custom queries.

Reviewers: btrahan, blc

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2625

Differential Revision: https://secure.phabricator.com/D6055

+31 -12
+1 -1
src/applications/paste/application/PhabricatorApplicationPaste.php
··· 36 36 'create/' => 'PhabricatorPasteEditController', 37 37 'edit/(?P<id>[1-9]\d*)/' => 'PhabricatorPasteEditController', 38 38 'filter/(?P<filter>\w+)/' => 'PhabricatorPasteListController', 39 - 'query/(?P<queryKey>\w+)/'=> 'PhabricatorPasteListController', 39 + 'query/(?P<queryKey>[^/]+)/'=> 'PhabricatorPasteListController', 40 40 'savedqueries/' => 'PhabricatorPasteQueriesController', 41 41 ), 42 42 );
+4
src/applications/paste/query/PhabricatorPasteSearchEngine.php
··· 105 105 return $this; 106 106 } 107 107 108 + public function getQueryResultsPageURI(PhabricatorSavedQuery $query) { 109 + return '/paste/query/'.$query->getQueryKey().'/'; 110 + } 111 + 108 112 }
+1 -1
src/applications/search/application/PhabricatorApplicationSearch.php
··· 34 34 'index/(?P<phid>[^/]+)/' => 'PhabricatorSearchIndexController', 35 35 'hovercard/(?P<mode>retrieve|test)/' => 36 36 'PhabricatorSearchHovercardController', 37 - 'name/(?P<queryKey>\w+)/' => 'PhabricatorSearchNameController', 37 + 'name/(?P<queryKey>[^/]+)/' => 'PhabricatorSearchNameController', 38 38 ), 39 39 ); 40 40 }
+9 -10
src/applications/search/controller/PhabricatorSearchNameController.php
··· 16 16 $request = $this->getRequest(); 17 17 $user = $request->getUser(); 18 18 19 - if ($this->queryKey) { 20 - $saved_query = id(new PhabricatorSavedQueryQuery()) 21 - ->setViewer($user) 22 - ->withQueryKeys(array($this->queryKey)) 23 - ->executeOne(); 24 - if (!$saved_query) { 25 - return new Aphront404Response(); 26 - } 27 - } else { 19 + $saved_query = id(new PhabricatorSavedQueryQuery()) 20 + ->setViewer($user) 21 + ->withQueryKeys(array($this->queryKey)) 22 + ->executeOne(); 23 + 24 + if (!$saved_query) { 28 25 return new Aphront404Response(); 29 26 } 27 + 28 + $engine = $saved_query->newEngine(); 30 29 31 30 if ($request->isFormPost()) { 32 31 $named_query = id(new PhabricatorNamedQuery()) ··· 42 41 } 43 42 44 43 return id(new AphrontRedirectResponse()) 45 - ->setURI('/search/'); 44 + ->setURI($engine->getQueryResultsPageURI($saved_query)); 46 45 } 47 46 48 47 $form = id(new AphrontFormView())
+9
src/applications/search/engine/PhabricatorApplicationSearchEngine.php
··· 34 34 */ 35 35 abstract public function buildSearchForm(PhabricatorSavedQuery $query); 36 36 37 + 38 + /** 39 + * Return an application URI corresponding to the results page of a query. 40 + * Normally, this is something like `/application/query/QUERYKEY/`. 41 + * 42 + * @param PhabricatorSavedQuery The query to build a URI for. 43 + * @return string URI where the query can be executed. 44 + */ 45 + abstract public function getQueryResultsPageURI(PhabricatorSavedQuery $query); 37 46 }
+7
src/applications/search/storage/PhabricatorSavedQuery.php
··· 31 31 throw new Exception(pht("Engine class is null.")); 32 32 } 33 33 34 + // Instantiate the engine to make sure it's valid. 35 + $this->newEngine(); 36 + 34 37 $serial = $this->getEngineClassName().serialize($this->parameters); 35 38 $this->queryKey = PhabricatorHash::digestForIndex($serial); 36 39 37 40 return parent::save(); 41 + } 42 + 43 + public function newEngine() { 44 + return newv($this->getEngineClassName(), array()); 38 45 } 39 46 40 47