@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.

Add better error checking to 'Add to Dashboard'

Summary: Ref T5307. Adds a better query check query, sets required for the name, adds the correct URI for cancelling.

Test Plan: Test a form without a name, fake a query string, test cancel button.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T5307

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

+20 -4
+20 -4
src/applications/dashboard/controller/PhabricatorDashboardQueryPanelInstallController.php
··· 12 12 $v_engine = $request->getURIData('engineKey'); 13 13 $v_query = $request->getURIData('queryKey'); 14 14 15 + $e_name = true; 16 + 15 17 // Validate Engines 16 18 $engines = PhabricatorApplicationSearchEngine::getAllEngines(); 17 19 foreach ($engines as $name => $engine) { ··· 26 28 // Validate Queries 27 29 $engine = $engines[$v_engine]; 28 30 $engine->setViewer($viewer); 29 - $queries = array_keys($engine->loadEnabledNamedQueries()); 30 - if (!in_array($v_query, $queries)) { 31 + $good_query = false; 32 + if ($engine->isBuiltinQuery($v_engine)) { 33 + $good_query = true; 34 + } else { 35 + $saved_query = id(new PhabricatorSavedQueryQuery()) 36 + ->setViewer($viewer) 37 + ->withEngineClassNames(array($v_engine)) 38 + ->withQueryKeys(array($v_query)) 39 + ->executeOne(); 40 + if ($saved_query) { 41 + $good_query = true; 42 + } 43 + } 44 + if (!$good_query) { 31 45 return new Aphront404Response(); 32 46 } 33 47 ··· 38 52 $v_name = $request->getStr('name'); 39 53 if (!$v_name) { 40 54 $errors[] = pht('You must provide a name for this panel.'); 55 + $e_name = pht('Required'); 41 56 } 42 57 43 58 $dashboard = id(new PhabricatorDashboardQuery()) ··· 127 142 $options = mpull($dashboards, 'getName', 'getID'); 128 143 asort($options); 129 144 130 - $redirect_uri = '#'; // ?? 145 + $redirect_uri = $engine->getQueryResultsPageURI($v_query); 131 146 132 147 $form = id(new AphrontFormView()) 133 148 ->setUser($viewer) ··· 138 153 id(new AphrontFormTextControl()) 139 154 ->setLabel(pht('Name')) 140 155 ->setName('name') 141 - ->setValue($v_name)) 156 + ->setValue($v_name) 157 + ->setError($e_name)) 142 158 ->appendChild( 143 159 id(new AphrontFormSelectControl()) 144 160 ->setUser($this->getViewer())