Differential D11789 Diff 28422 src/applications/diffusion/controller/DiffusionBrowseSearchController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/controller/DiffusionBrowseSearchController.php
| Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | private function renderSearchResults() { | ||||
| $page = $this->getRequest()->getInt('page', 0); | $page = $this->getRequest()->getInt('page', 0); | ||||
| $pager = new AphrontPagerView(); | $pager = new AphrontPagerView(); | ||||
| $pager->setPageSize($limit); | $pager->setPageSize($limit); | ||||
| $pager->setOffset($page); | $pager->setOffset($page); | ||||
| $pager->setURI($this->getRequest()->getRequestURI(), 'page'); | $pager->setURI($this->getRequest()->getRequestURI(), 'page'); | ||||
| $search_mode = null; | $search_mode = null; | ||||
| try { | switch ($repository->getVersionControlSystem()) { | ||||
| case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: | |||||
| $results = array(); | |||||
| break; | |||||
| default: | |||||
| if (strlen($this->getRequest()->getStr('grep'))) { | if (strlen($this->getRequest()->getStr('grep'))) { | ||||
| $search_mode = 'grep'; | $search_mode = 'grep'; | ||||
| $query_string = $this->getRequest()->getStr('grep'); | $query_string = $this->getRequest()->getStr('grep'); | ||||
| $results = $this->callConduitWithDiffusionRequest( | $results = $this->callConduitWithDiffusionRequest( | ||||
| 'diffusion.searchquery', | 'diffusion.searchquery', | ||||
| array( | array( | ||||
| 'grep' => $query_string, | 'grep' => $query_string, | ||||
| 'commit' => $drequest->getStableCommit(), | 'commit' => $drequest->getStableCommit(), | ||||
| 'path' => $drequest->getPath(), | 'path' => $drequest->getPath(), | ||||
| 'limit' => $limit + 1, | 'limit' => $limit + 1, | ||||
| 'offset' => $page, | 'offset' => $page, | ||||
| )); | )); | ||||
| } else { // Filename search. | } else { // Filename search. | ||||
| $search_mode = 'find'; | $search_mode = 'find'; | ||||
| $query_string = $this->getRequest()->getStr('find'); | $query_string = $this->getRequest()->getStr('find'); | ||||
| $results = $this->callConduitWithDiffusionRequest( | $results = $this->callConduitWithDiffusionRequest( | ||||
| 'diffusion.querypaths', | 'diffusion.querypaths', | ||||
| array( | array( | ||||
| 'pattern' => $query_string, | 'pattern' => $query_string, | ||||
| 'commit' => $drequest->getStableCommit(), | 'commit' => $drequest->getStableCommit(), | ||||
| 'path' => $drequest->getPath(), | 'path' => $drequest->getPath(), | ||||
| 'limit' => $limit + 1, | 'limit' => $limit + 1, | ||||
| 'offset' => $page, | 'offset' => $page, | ||||
| )); | )); | ||||
| } | } | ||||
| } catch (ConduitException $ex) { | break; | ||||
| $err = $ex->getErrorDescription(); | |||||
| if ($err != '') { | |||||
| return id(new PHUIErrorView()) | |||||
| ->setTitle(pht('Search Error')) | |||||
| ->appendChild($err); | |||||
| } | |||||
| } | } | ||||
epriestley: This one could still potentially pop out as `ConduitClientException`, right? | |||||
Not Done Inline ActionsYes, in the proxied case. I wasn't sure how the ConduitClientException gets constructed in terms of the ConduitException its wrapping; maybe this can just getErrorDescription? In practice, this is just making a little search error that tells you if something is weird on your system, e.g. the vcs grep command failed for some reason. maybe it can just be omitted entirely? btrahan: Yes, in the proxied case.
I wasn't sure how the ConduitClientException gets constructed in… | |||||
| $results = $pager->sliceResults($results); | $results = $pager->sliceResults($results); | ||||
| if ($search_mode == 'grep') { | if ($search_mode == 'grep') { | ||||
| $table = $this->renderGrepResults($results); | $table = $this->renderGrepResults($results); | ||||
| $header = pht( | $header = pht( | ||||
| 'File content matching "%s" under "%s"', | 'File content matching "%s" under "%s"', | ||||
| $query_string, | $query_string, | ||||
| ▲ Show 20 Lines • Show All 112 Lines • Show Last 20 Lines | |||||
This one could still potentially pop out as ConduitClientException, right?