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

Update Slowvote for handleRequest

Summary: Moves to use handleRequest

Test Plan: Make a new poll, edit, see list

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

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

+47 -82
+6 -12
src/applications/slowvote/controller/PhabricatorSlowvoteCloseController.php
··· 3 3 final class PhabricatorSlowvoteCloseController 4 4 extends PhabricatorSlowvoteController { 5 5 6 - private $id; 7 - 8 - public function willProcessRequest(array $data) { 9 - $this->id = $data['id']; 10 - } 11 - 12 - public function processRequest() { 13 - $request = $this->getRequest(); 14 - $user = $request->getUser(); 6 + public function handleRequest(AphrontRequest $request) { 7 + $viewer = $request->getViewer(); 8 + $id = $request->getURIData('id'); 15 9 16 10 $poll = id(new PhabricatorSlowvoteQuery()) 17 - ->setViewer($user) 18 - ->withIDs(array($this->id)) 11 + ->setViewer($viewer) 12 + ->withIDs(array($id)) 19 13 ->requireCapabilities( 20 14 array( 21 15 PhabricatorPolicyCapability::CAN_VIEW, ··· 42 36 ->setNewValue($new_status); 43 37 44 38 id(new PhabricatorSlowvoteEditor()) 45 - ->setActor($user) 39 + ->setActor($viewer) 46 40 ->setContentSourceFromRequest($request) 47 41 ->setContinueOnNoEffect(true) 48 42 ->setContinueOnMissingFields(true)
+7 -13
src/applications/slowvote/controller/PhabricatorSlowvoteCommentController.php
··· 3 3 final class PhabricatorSlowvoteCommentController 4 4 extends PhabricatorSlowvoteController { 5 5 6 - private $id; 7 - 8 - public function willProcessRequest(array $data) { 9 - $this->id = $data['id']; 10 - } 11 - 12 - public function processRequest() { 13 - $request = $this->getRequest(); 14 - $user = $request->getUser(); 6 + public function handleRequest(AphrontRequest $request) { 7 + $viewer = $request->getViewer(); 8 + $id = $request->getURIData('id'); 15 9 16 10 if (!$request->isFormPost()) { 17 11 return new Aphront400Response(); 18 12 } 19 13 20 14 $poll = id(new PhabricatorSlowvoteQuery()) 21 - ->setViewer($user) 22 - ->withIDs(array($this->id)) 15 + ->setViewer($viewer) 16 + ->withIDs(array($id)) 23 17 ->executeOne(); 24 18 if (!$poll) { 25 19 return new Aphront404Response(); ··· 38 32 ->setContent($request->getStr('comment'))); 39 33 40 34 $editor = id(new PhabricatorSlowvoteEditor()) 41 - ->setActor($user) 35 + ->setActor($viewer) 42 36 ->setContinueOnNoEffect($request->isContinueRequest()) 43 37 ->setContentSourceFromRequest($request) 44 38 ->setIsPreview($is_preview); ··· 57 51 58 52 if ($request->isAjax() && $is_preview) { 59 53 return id(new PhabricatorApplicationTransactionResponse()) 60 - ->setViewer($user) 54 + ->setViewer($viewer) 61 55 ->setTransactions($xactions) 62 56 ->setIsPreview($is_preview); 63 57 } else {
+12 -19
src/applications/slowvote/controller/PhabricatorSlowvoteEditController.php
··· 3 3 final class PhabricatorSlowvoteEditController 4 4 extends PhabricatorSlowvoteController { 5 5 6 - private $id; 7 - 8 - public function willProcessRequest(array $data) { 9 - $this->id = idx($data, 'id'); 10 - } 11 - 12 - public function processRequest() { 13 - 14 - $request = $this->getRequest(); 15 - $user = $request->getUser(); 6 + public function handleRequest(AphrontRequest $request) { 7 + $viewer = $request->getViewer(); 8 + $id = $request->getURIData('id'); 16 9 17 - if ($this->id) { 10 + if ($id) { 18 11 $poll = id(new PhabricatorSlowvoteQuery()) 19 - ->setViewer($user) 20 - ->withIDs(array($this->id)) 12 + ->setViewer($viewer) 13 + ->withIDs(array($id)) 21 14 ->requireCapabilities( 22 15 array( 23 16 PhabricatorPolicyCapability::CAN_VIEW, ··· 29 22 } 30 23 $is_new = false; 31 24 } else { 32 - $poll = PhabricatorSlowvotePoll::initializeNewPoll($user); 25 + $poll = PhabricatorSlowvotePoll::initializeNewPoll($viewer); 33 26 $is_new = true; 34 27 } 35 28 ··· 119 112 ->setNewValue(array('=' => array_fuse($v_projects))); 120 113 121 114 $editor = id(new PhabricatorSlowvoteEditor()) 122 - ->setActor($user) 115 + ->setActor($viewer) 123 116 ->setContinueOnNoEffect(true) 124 117 ->setContentSourceFromRequest($request); 125 118 ··· 153 146 'protracted deliberation.')); 154 147 155 148 $form = id(new AphrontFormView()) 156 - ->setUser($user) 149 + ->setUser($viewer) 157 150 ->appendChild($instructions) 158 151 ->appendChild( 159 152 id(new AphrontFormTextAreaControl()) ··· 164 157 ->setError($e_question)) 165 158 ->appendChild( 166 159 id(new PhabricatorRemarkupControl()) 167 - ->setUser($user) 160 + ->setUser($viewer) 168 161 ->setLabel(pht('Description')) 169 162 ->setName('description') 170 163 ->setValue($v_description)) ··· 232 225 } 233 226 234 227 $policies = id(new PhabricatorPolicyQuery()) 235 - ->setViewer($user) 228 + ->setViewer($viewer) 236 229 ->setObject($poll) 237 230 ->execute(); 238 231 ··· 253 246 $v_shuffle)) 254 247 ->appendChild( 255 248 id(new AphrontFormPolicyControl()) 256 - ->setUser($user) 249 + ->setUser($viewer) 257 250 ->setName('viewPolicy') 258 251 ->setPolicyObject($poll) 259 252 ->setPolicies($policies)
+3 -7
src/applications/slowvote/controller/PhabricatorSlowvoteListController.php
··· 3 3 final class PhabricatorSlowvoteListController 4 4 extends PhabricatorSlowvoteController { 5 5 6 - private $queryKey; 7 - 8 6 public function shouldAllowPublic() { 9 7 return true; 10 8 } 11 9 12 - public function willProcessRequest(array $data) { 13 - $this->queryKey = idx($data, 'queryKey'); 14 - } 10 + public function handleRequest(AphrontRequest $request) { 11 + $querykey = $request->getURIData('queryKey'); 15 12 16 - public function processRequest() { 17 13 $controller = id(new PhabricatorApplicationSearchController()) 18 - ->setQueryKey($this->queryKey) 14 + ->setQueryKey($querykey) 19 15 ->setSearchEngine(new PhabricatorSlowvoteSearchEngine()) 20 16 ->setNavigation($this->buildSideNavView()); 21 17
+7 -13
src/applications/slowvote/controller/PhabricatorSlowvotePollController.php
··· 3 3 final class PhabricatorSlowvotePollController 4 4 extends PhabricatorSlowvoteController { 5 5 6 - private $id; 7 - 8 - public function willProcessRequest(array $data) { 9 - $this->id = $data['id']; 10 - } 11 - 12 - public function processRequest() { 13 - $request = $this->getRequest(); 14 - $user = $request->getUser(); 6 + public function handleRequest(AphrontRequest $request) { 7 + $viewer = $request->getViewer(); 8 + $id = $request->getURIData('id'); 15 9 16 10 $poll = id(new PhabricatorSlowvoteQuery()) 17 - ->setViewer($user) 18 - ->withIDs(array($this->id)) 11 + ->setViewer($viewer) 12 + ->withIDs(array($id)) 19 13 ->needOptions(true) 20 14 ->needChoices(true) 21 15 ->needViewerChoices(true) ··· 26 20 27 21 $poll_view = id(new SlowvoteEmbedView()) 28 22 ->setHeadless(true) 29 - ->setUser($user) 23 + ->setUser($viewer) 30 24 ->setPoll($poll); 31 25 32 26 if ($request->isAjax()) { ··· 44 38 45 39 $header = id(new PHUIHeaderView()) 46 40 ->setHeader($poll->getQuestion()) 47 - ->setUser($user) 41 + ->setUser($viewer) 48 42 ->setStatus($header_icon, $header_color, $header_name) 49 43 ->setPolicyObject($poll); 50 44
+12 -18
src/applications/slowvote/controller/PhabricatorSlowvoteVoteController.php
··· 3 3 final class PhabricatorSlowvoteVoteController 4 4 extends PhabricatorSlowvoteController { 5 5 6 - private $id; 7 - 8 - public function willProcessRequest(array $data) { 9 - $this->id = $data['id']; 10 - } 11 - 12 - public function processRequest() { 13 - $request = $this->getRequest(); 14 - $user = $request->getUser(); 6 + public function handleRequest(AphrontRequest $request) { 7 + $viewer = $request->getViewer(); 8 + $id = $request->getURIData('id'); 15 9 16 10 $poll = id(new PhabricatorSlowvoteQuery()) 17 - ->setViewer($user) 18 - ->withIDs(array($this->id)) 11 + ->setViewer($viewer) 12 + ->withIDs(array($id)) 19 13 ->needOptions(true) 20 14 ->needViewerChoices(true) 21 15 ->executeOne(); ··· 27 21 } 28 22 29 23 $options = $poll->getOptions(); 30 - $user_choices = $poll->getViewerChoices($user); 24 + $viewer_choices = $poll->getViewerChoices($viewer); 31 25 32 - $old_votes = mpull($user_choices, null, 'getOptionID'); 26 + $old_votes = mpull($viewer_choices, null, 'getOptionID'); 33 27 34 28 if ($request->isAjax()) { 35 29 $vote = $request->getInt('vote'); ··· 50 44 } 51 45 } 52 46 53 - $this->updateVotes($user, $poll, $old_votes, $votes); 47 + $this->updateVotes($viewer, $poll, $old_votes, $votes); 54 48 55 49 $updated_choices = id(new PhabricatorSlowvoteChoice())->loadAllWhere( 56 50 'pollID = %d AND authorPHID = %s', 57 51 $poll->getID(), 58 - $user->getPHID()); 52 + $viewer->getPHID()); 59 53 60 54 $embed = id(new SlowvoteEmbedView()) 61 55 ->setPoll($poll) ··· 76 70 $votes = $request->getArr('vote'); 77 71 $votes = array_fuse($votes, $votes); 78 72 79 - $this->updateVotes($user, $poll, $old_votes, $votes); 73 + $this->updateVotes($viewer, $poll, $old_votes, $votes); 80 74 81 75 return id(new AphrontRedirectResponse())->setURI('/V'.$poll->getID()); 82 76 } 83 77 84 - private function updateVotes($user, $poll, $old_votes, $votes) { 78 + private function updateVotes($viewer, $poll, $old_votes, $votes) { 85 79 if (!empty($votes) && count($votes) > 1 && 86 80 $poll->getMethod() == PhabricatorSlowvotePoll::METHOD_PLURALITY) { 87 81 return id(new Aphront400Response()); ··· 99 93 } 100 94 101 95 id(new PhabricatorSlowvoteChoice()) 102 - ->setAuthorPHID($user->getPHID()) 96 + ->setAuthorPHID($viewer->getPHID()) 103 97 ->setPollID($poll->getID()) 104 98 ->setOptionID($vote) 105 99 ->save();