@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 Phriction for handleRequest

Summary: Updates Phriction calls to handleRequest

Test Plan: Create, Delete, Move a Phriction Document. Check history, diff.

Reviewers: btrahan, epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T8628

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

+60 -93
+8 -14
src/applications/phriction/controller/PhrictionDeleteController.php
··· 2 2 3 3 final class PhrictionDeleteController extends PhrictionController { 4 4 5 - private $id; 6 - 7 - public function willProcessRequest(array $data) { 8 - $this->id = $data['id']; 9 - } 10 - 11 - public function processRequest() { 12 - $request = $this->getRequest(); 13 - $user = $request->getUser(); 5 + public function handleRequest(AphrontRequest $request) { 6 + $viewer = $request->getViewer(); 7 + $id = $request->getURIData('id'); 14 8 15 9 $document = id(new PhrictionDocumentQuery()) 16 - ->setViewer($user) 17 - ->withIDs(array($this->id)) 10 + ->setViewer($viewer) 11 + ->withIDs(array($id)) 18 12 ->needContent(true) 19 13 ->requireCapabilities( 20 14 array( ··· 36 30 ->setNewValue(true); 37 31 38 32 $editor = id(new PhrictionTransactionEditor()) 39 - ->setActor($user) 33 + ->setActor($viewer) 40 34 ->setContentSourceFromRequest($request) 41 35 ->setContinueOnNoEffect(true); 42 36 try { ··· 49 43 50 44 if ($e_text) { 51 45 $dialog = id(new AphrontDialogView()) 52 - ->setUser($user) 46 + ->setUser($viewer) 53 47 ->setTitle(pht('Can Not Delete Document!')) 54 48 ->appendChild($e_text) 55 49 ->addCancelButton($document_uri); 56 50 } else { 57 51 $dialog = id(new AphrontDialogView()) 58 - ->setUser($user) 52 + ->setUser($viewer) 59 53 ->setTitle(pht('Delete Document?')) 60 54 ->appendChild( 61 55 pht('Really delete this document? You can recover it later by '.
+10 -16
src/applications/phriction/controller/PhrictionDiffController.php
··· 2 2 3 3 final class PhrictionDiffController extends PhrictionController { 4 4 5 - private $id; 6 - 7 5 public function shouldAllowPublic() { 8 6 return true; 9 7 } 10 8 11 - public function willProcessRequest(array $data) { 12 - $this->id = $data['id']; 13 - } 14 - 15 - public function processRequest() { 16 - $request = $this->getRequest(); 17 - $user = $request->getUser(); 9 + public function handleRequest(AphrontRequest $request) { 10 + $viewer = $request->getViewer(); 11 + $id = $request->getURIData('id'); 18 12 19 13 $document = id(new PhrictionDocumentQuery()) 20 - ->setViewer($user) 21 - ->withIDs(array($this->id)) 14 + ->setViewer($viewer) 15 + ->withIDs(array($id)) 22 16 ->needContent(true) 23 17 ->executeOne(); 24 18 if (!$document) { ··· 73 67 $whitespace_mode = DifferentialChangesetParser::WHITESPACE_SHOW_ALL; 74 68 75 69 $parser = id(new DifferentialChangesetParser()) 76 - ->setUser($user) 70 + ->setUser($viewer) 77 71 ->setChangeset($changeset) 78 72 ->setRenderingReference("{$l},{$r}"); 79 73 ··· 81 75 $parser->setWhitespaceMode($whitespace_mode); 82 76 83 77 $engine = new PhabricatorMarkupEngine(); 84 - $engine->setViewer($user); 78 + $engine->setViewer($viewer); 85 79 $engine->process(); 86 80 $parser->setMarkupEngine($engine); 87 81 ··· 262 256 private function renderComparisonTable(array $content) { 263 257 assert_instances_of($content, 'PhrictionContent'); 264 258 265 - $user = $this->getRequest()->getUser(); 259 + $viewer = $this->getViewer(); 266 260 267 261 $phids = mpull($content, 'getAuthorPHID'); 268 262 $handles = $this->loadViewerHandles($phids); ··· 278 272 $author, 279 273 pht('Version %s', $c->getVersion()))) 280 274 ->addAttribute(pht('%s %s', 281 - phabricator_date($c->getDateCreated(), $user), 282 - phabricator_time($c->getDateCreated(), $user))); 275 + phabricator_date($c->getDateCreated(), $viewer), 276 + phabricator_time($c->getDateCreated(), $viewer))); 283 277 284 278 if ($c->getDescription()) { 285 279 $item->addAttribute($c->getDescription());
+14 -18
src/applications/phriction/controller/PhrictionDocumentController.php
··· 9 9 return true; 10 10 } 11 11 12 - public function willProcessRequest(array $data) { 13 - $this->slug = $data['slug']; 14 - } 15 - 16 - public function processRequest() { 17 - $request = $this->getRequest(); 18 - $user = $request->getUser(); 12 + public function handleRequest(AphrontRequest $request) { 13 + $viewer = $request->getViewer(); 14 + $this->slug = $request->getURIData('slug'); 19 15 20 16 $slug = PhabricatorSlug::normalize($this->slug); 21 17 if ($slug != $this->slug) { ··· 27 23 require_celerity_resource('phriction-document-css'); 28 24 29 25 $document = id(new PhrictionDocumentQuery()) 30 - ->setViewer($user) 26 + ->setViewer($viewer) 31 27 ->withSlugs(array($slug)) 32 28 ->executeOne(); 33 29 ··· 39 35 40 36 if (!$document) { 41 37 42 - $document = PhrictionDocument::initializeNewDocument($user, $slug); 38 + $document = PhrictionDocument::initializeNewDocument($viewer, $slug); 43 39 44 40 $create_uri = '/phriction/edit/?slug='.$slug; 45 41 ··· 67 63 } 68 64 69 65 if ($content->getID() != $document->getContentID()) { 70 - $vdate = phabricator_datetime($content->getDateCreated(), $user); 66 + $vdate = phabricator_datetime($content->getDateCreated(), $viewer); 71 67 $version_note = new PHUIInfoView(); 72 68 $version_note->setSeverity(PHUIInfoView::SEVERITY_NOTICE); 73 69 $version_note->appendChild( ··· 87 83 if ($current_status == PhrictionChangeType::CHANGE_EDIT || 88 84 $current_status == PhrictionChangeType::CHANGE_MOVE_HERE) { 89 85 90 - $core_content = $content->renderContent($user); 86 + $core_content = $content->renderContent($viewer); 91 87 } else if ($current_status == PhrictionChangeType::CHANGE_DELETE) { 92 88 $notice = new PHUIInfoView(); 93 89 $notice->setSeverity(PHUIInfoView::SEVERITY_NOTICE); ··· 112 108 // If the new document exists and the viewer can see it, provide a link 113 109 // to it. Otherwise, render a generic message. 114 110 $new_docs = id(new PhrictionDocumentQuery()) 115 - ->setViewer($user) 111 + ->setViewer($viewer) 116 112 ->withIDs(array($new_doc_id)) 117 113 ->execute(); 118 114 if ($new_docs) { ··· 157 153 158 154 // If the old document exists and is visible, provide a link to it. 159 155 $from_docs = id(new PhrictionDocumentQuery()) 160 - ->setViewer($user) 156 + ->setViewer($viewer) 161 157 ->withIDs(array($from_doc_id)) 162 158 ->execute(); 163 159 if ($from_docs) { ··· 183 179 184 180 $children = $this->renderDocumentChildren($slug); 185 181 186 - $actions = $this->buildActionView($user, $document); 182 + $actions = $this->buildActionView($viewer, $document); 187 183 188 184 $crumbs = $this->buildApplicationCrumbs(); 189 185 $crumbs->setBorder(true); ··· 201 197 ->setDropdownMenu($actions); 202 198 203 199 $header = id(new PHUIHeaderView()) 204 - ->setUser($user) 200 + ->setUser($viewer) 205 201 ->setPolicyObject($document) 206 202 ->setHeader($page_title) 207 203 ->addActionLink($action_button); ··· 257 253 } 258 254 259 255 private function buildActionView( 260 - PhabricatorUser $user, 256 + PhabricatorUser $viewer, 261 257 PhrictionDocument $document) { 262 258 $can_edit = PhabricatorPolicyFilter::hasCapability( 263 - $user, 259 + $viewer, 264 260 $document, 265 261 PhabricatorPolicyCapability::CAN_EDIT); 266 262 267 263 $slug = PhabricatorSlug::normalize($this->slug); 268 264 269 265 $action_view = id(new PhabricatorActionListView()) 270 - ->setUser($user) 266 + ->setUser($viewer) 271 267 ->setObjectURI($this->getRequest()->getRequestURI()) 272 268 ->setObject($document); 273 269
+13 -20
src/applications/phriction/controller/PhrictionEditController.php
··· 3 3 final class PhrictionEditController 4 4 extends PhrictionController { 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 10 $current_version = null; 18 - if ($this->id) { 11 + if ($id) { 19 12 $document = id(new PhrictionDocumentQuery()) 20 - ->setViewer($user) 21 - ->withIDs(array($this->id)) 13 + ->setViewer($viewer) 14 + ->withIDs(array($id)) 22 15 ->needContent(true) 23 16 ->requireCapabilities( 24 17 array( ··· 53 46 } 54 47 55 48 $document = id(new PhrictionDocumentQuery()) 56 - ->setViewer($user) 49 + ->setViewer($viewer) 57 50 ->withSlugs(array($slug)) 58 51 ->needContent(true) 59 52 ->executeOne(); ··· 62 55 $content = $document->getContent(); 63 56 $current_version = $content->getVersion(); 64 57 } else { 65 - $document = PhrictionDocument::initializeNewDocument($user, $slug); 58 + $document = PhrictionDocument::initializeNewDocument($viewer, $slug); 66 59 $content = $document->getContent(); 67 60 } 68 61 } ··· 78 71 } 79 72 $draft = id(new PhabricatorDraft())->loadOneWhere( 80 73 'authorPHID = %s AND draftKey = %s', 81 - $user->getPHID(), 74 + $viewer->getPHID(), 82 75 $draft_key); 83 76 } 84 77 ··· 141 134 ->setNewValue($v_edit); 142 135 143 136 $editor = id(new PhrictionTransactionEditor()) 144 - ->setActor($user) 137 + ->setActor($viewer) 145 138 ->setContentSourceFromRequest($request) 146 139 ->setContinueOnNoEffect(true) 147 140 ->setDescription($notes) ··· 198 191 $cancel_uri = PhrictionDocument::getSlugURI($document->getSlug()); 199 192 200 193 $policies = id(new PhabricatorPolicyQuery()) 201 - ->setViewer($user) 194 + ->setViewer($viewer) 202 195 ->setObject($document) 203 196 ->execute(); 204 197 $view_capability = PhabricatorPolicyCapability::CAN_VIEW; 205 198 $edit_capability = PhabricatorPolicyCapability::CAN_EDIT; 206 199 207 200 $form = id(new AphrontFormView()) 208 - ->setUser($user) 201 + ->setUser($viewer) 209 202 ->addHiddenInput('slug', $document->getSlug()) 210 203 ->addHiddenInput('nodraft', $request->getBool('nodraft')) 211 204 ->addHiddenInput('contentVersion', $current_version) ··· 228 221 ->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL) 229 222 ->setName('content') 230 223 ->setID('document-textarea') 231 - ->setUser($user)) 224 + ->setUser($viewer)) 232 225 ->appendChild( 233 226 id(new AphrontFormPolicyControl()) 234 227 ->setName('viewPolicy')
+6 -11
src/applications/phriction/controller/PhrictionHistoryController.php
··· 9 9 return true; 10 10 } 11 11 12 - public function willProcessRequest(array $data) { 13 - $this->slug = $data['slug']; 14 - } 15 - 16 - public function processRequest() { 17 - 18 - $request = $this->getRequest(); 19 - $user = $request->getUser(); 12 + public function handleRequest(AphrontRequest $request) { 13 + $viewer = $request->getViewer(); 14 + $this->slug = $request->getURIData('slug'); 20 15 21 16 $document = id(new PhrictionDocumentQuery()) 22 - ->setViewer($user) 17 + ->setViewer($viewer) 23 18 ->withSlugs(array(PhabricatorSlug::normalize($this->slug))) 24 19 ->needContent(true) 25 20 ->executeOne(); ··· 102 97 ), 103 98 pht('Version %s', $version))) 104 99 ->addAttribute(pht('%s %s', 105 - phabricator_date($content->getDateCreated(), $user), 106 - phabricator_time($content->getDateCreated(), $user))); 100 + phabricator_date($content->getDateCreated(), $viewer), 101 + phabricator_time($content->getDateCreated(), $viewer))); 107 102 108 103 if ($content->getDescription()) { 109 104 $item->addAttribute($content->getDescription());
+3 -7
src/applications/phriction/controller/PhrictionListController.php
··· 3 3 final class PhrictionListController 4 4 extends PhrictionController { 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 PhrictionSearchEngine()) 20 16 ->setNavigation($this->buildSideNavView()); 21 17
+6 -7
src/applications/phriction/controller/PhrictionNewController.php
··· 2 2 3 3 final class PhrictionNewController extends PhrictionController { 4 4 5 - public function processRequest() { 6 - $request = $this->getRequest(); 7 - $user = $request->getUser(); 8 - $slug = PhabricatorSlug::normalize($request->getStr('slug')); 5 + public function handleRequest(AphrontRequest $request) { 6 + $viewer = $request->getViewer(); 7 + $slug = PhabricatorSlug::normalize($request->getStr('slug')); 9 8 10 9 if ($request->isFormPost()) { 11 10 $document = id(new PhrictionDocumentQuery()) 12 - ->setViewer($user) 11 + ->setViewer($viewer) 13 12 ->withSlugs(array($slug)) 14 13 ->executeOne(); 15 14 $prompt = $request->getStr('prompt', 'no'); ··· 20 19 $dialog = new AphrontDialogView(); 21 20 $dialog->setSubmitURI('/phriction/new/') 22 21 ->setTitle(pht('Edit Existing Document?')) 23 - ->setUser($user) 22 + ->setUser($viewer) 24 23 ->appendChild(pht( 25 24 'The document %s already exists. Do you want to edit it instead?', 26 25 phutil_tag('tt', array(), $slug))) ··· 48 47 ->setName('slug')); 49 48 50 49 $dialog = id(new AphrontDialogView()) 51 - ->setUser($user) 50 + ->setUser($viewer) 52 51 ->setTitle(pht('New Document')) 53 52 ->setSubmitURI('/phriction/new/') 54 53 ->appendChild(phutil_tag('p',