1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-19 13:22:42 +01:00

Update Differential for handleRequest

Summary: Moves from processRequest to handleRequest.

Test Plan: New diff, edit diff, leave comment, view list, browse revisions, etc.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D14252
This commit is contained in:
Chad Little 2015-10-11 08:18:42 -07:00
parent 2f6d3119f5
commit bb37ad65a2
8 changed files with 47 additions and 91 deletions

View file

@ -3,19 +3,13 @@
final class DifferentialCommentPreviewController final class DifferentialCommentPreviewController
extends DifferentialController { extends DifferentialController {
private $id; public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
public function willProcessRequest(array $data) { $id = $request->getURIData('id');
$this->id = $data['id'];
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
$revision = id(new DifferentialRevisionQuery()) $revision = id(new DifferentialRevisionQuery())
->setViewer($viewer) ->setViewer($viewer)
->withIDs(array($this->id)) ->withIDs(array($id))
->executeOne(); ->executeOne();
if (!$revision) { if (!$revision) {
return new Aphront404Response(); return new Aphront404Response();
@ -119,7 +113,7 @@ final class DifferentialCommentPreviewController
$metadata['action'] = $action; $metadata['action'] = $action;
} }
$draft_key = 'differential-comment-'.$this->id; $draft_key = 'differential-comment-'.$id;
$draft = id(new PhabricatorDraft()) $draft = id(new PhabricatorDraft())
->setAuthorPHID($viewer->getPHID()) ->setAuthorPHID($viewer->getPHID())
->setDraftKey($draft_key) ->setDraftKey($draft_key)

View file

@ -3,15 +3,9 @@
final class DifferentialCommentSaveController final class DifferentialCommentSaveController
extends DifferentialController { extends DifferentialController {
private $id; public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
public function willProcessRequest(array $data) { $id = $request->getURIData('id');
$this->id = $data['id'];
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
if (!$request->isFormPost()) { if (!$request->isFormPost()) {
return new Aphront400Response(); return new Aphront400Response();
@ -19,7 +13,7 @@ final class DifferentialCommentSaveController
$revision = id(new DifferentialRevisionQuery()) $revision = id(new DifferentialRevisionQuery())
->setViewer($viewer) ->setViewer($viewer)
->withIDs(array($this->id)) ->withIDs(array($id))
->needReviewerStatus(true) ->needReviewerStatus(true)
->needReviewerAuthority(true) ->needReviewerAuthority(true)
->executeOne(); ->executeOne();

View file

@ -2,23 +2,17 @@
final class DifferentialDiffViewController extends DifferentialController { final class DifferentialDiffViewController extends DifferentialController {
private $id;
public function shouldAllowPublic() { public function shouldAllowPublic() {
return true; return true;
} }
public function willProcessRequest(array $data) { public function handleRequest(AphrontRequest $request) {
$this->id = $data['id']; $viewer = $this->getViewer();
} $id = $request->getURIData('id');
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
$diff = id(new DifferentialDiffQuery()) $diff = id(new DifferentialDiffQuery())
->setViewer($viewer) ->setViewer($viewer)
->withIDs(array($this->id)) ->withIDs(array($id))
->executeOne(); ->executeOne();
if (!$diff) { if (!$diff) {
return new Aphront404Response(); return new Aphront404Response();

View file

@ -3,20 +3,11 @@
final class DifferentialRevisionCloseDetailsController final class DifferentialRevisionCloseDetailsController
extends DifferentialController { extends DifferentialController {
private $phid; public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
public function willProcessRequest(array $data) {
$this->phid = idx($data, 'phid');
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
$xaction_phid = $this->phid;
$xaction = id(new PhabricatorObjectQuery()) $xaction = id(new PhabricatorObjectQuery())
->withPHIDs(array($xaction_phid)) ->withPHIDs(array($request->getURIData('phid')))
->setViewer($viewer) ->setViewer($viewer)
->executeOne(); ->executeOne();
if (!$xaction) { if (!$xaction) {

View file

@ -3,24 +3,18 @@
final class DifferentialRevisionEditController final class DifferentialRevisionEditController
extends DifferentialController { extends DifferentialController {
private $id; public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
$id = $request->getURIData('id');
public function willProcessRequest(array $data) { if (!$id) {
$this->id = idx($data, 'id'); $id = $request->getInt('revisionID');
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
if (!$this->id) {
$this->id = $request->getInt('revisionID');
} }
if ($this->id) { if ($id) {
$revision = id(new DifferentialRevisionQuery()) $revision = id(new DifferentialRevisionQuery())
->setViewer($viewer) ->setViewer($viewer)
->withIDs(array($this->id)) ->withIDs(array($id))
->needRelationships(true) ->needRelationships(true)
->needReviewerStatus(true) ->needReviewerStatus(true)
->needActiveDiffs(true) ->needActiveDiffs(true)

View file

@ -11,9 +11,8 @@ final class DifferentialRevisionLandController extends DifferentialController {
$this->strategyClass = $data['strategy']; $this->strategyClass = $data['strategy'];
} }
public function processRequest() { public function handleRequest(AphrontRequest $request) {
$request = $this->getRequest(); $viewer = $this->getViewer();
$viewer = $request->getUser();
$revision_id = $this->revisionID; $revision_id = $this->revisionID;

View file

@ -2,19 +2,13 @@
final class DifferentialRevisionListController extends DifferentialController { final class DifferentialRevisionListController extends DifferentialController {
private $queryKey;
public function shouldAllowPublic() { public function shouldAllowPublic() {
return true; return true;
} }
public function willProcessRequest(array $data) { public function handleRequest(AphrontRequest $request) {
$this->queryKey = idx($data, 'queryKey');
}
public function processRequest() {
$controller = id(new PhabricatorApplicationSearchController()) $controller = id(new PhabricatorApplicationSearchController())
->setQueryKey($this->queryKey) ->setQueryKey($request->getURIData('queryKey'))
->setSearchEngine(new DifferentialRevisionSearchEngine()) ->setSearchEngine(new DifferentialRevisionSearchEngine())
->setNavigation($this->buildSideNavView()); ->setNavigation($this->buildSideNavView());

View file

@ -8,15 +8,11 @@ final class DifferentialRevisionViewController extends DifferentialController {
return true; return true;
} }
public function willProcessRequest(array $data) { public function handleRequest(AphrontRequest $request) {
$this->revisionID = $data['id']; $viewer = $this->getViewer();
} $this->revisionID = $request->getURIData('id');
public function processRequest() { $viewer_is_anonymous = !$viewer->isLoggedIn();
$request = $this->getRequest();
$user = $request->getUser();
$viewer_is_anonymous = !$user->isLoggedIn();
$revision = id(new DifferentialRevisionQuery()) $revision = id(new DifferentialRevisionQuery())
->withIDs(array($this->revisionID)) ->withIDs(array($this->revisionID))
@ -68,7 +64,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
$repository = $revision->getRepository(); $repository = $revision->getRepository();
} else { } else {
$repository = id(new PhabricatorRepositoryQuery()) $repository = id(new PhabricatorRepositoryQuery())
->setViewer($user) ->setViewer($viewer)
->withPHIDs(array($repository_phid)) ->withPHIDs(array($repository_phid))
->executeOne(); ->executeOne();
} }
@ -117,7 +113,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
$revision->loadCommitPHIDs(), $revision->loadCommitPHIDs(),
array( array(
$revision->getAuthorPHID(), $revision->getAuthorPHID(),
$user->getPHID(), $viewer->getPHID(),
)); ));
foreach ($revision->getAttached() as $type => $phids) { foreach ($revision->getAttached() as $type => $phids) {
@ -130,7 +126,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
$revision, $revision,
PhabricatorCustomField::ROLE_VIEW); PhabricatorCustomField::ROLE_VIEW);
$field_list->setViewer($user); $field_list->setViewer($viewer);
$field_list->readFieldsFromStorage($revision); $field_list->readFieldsFromStorage($revision);
$warning_handle_map = array(); $warning_handle_map = array();
@ -174,7 +170,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
$new = array_select_keys($changesets, $new_ids); $new = array_select_keys($changesets, $new_ids);
$query = id(new DifferentialInlineCommentQuery()) $query = id(new DifferentialInlineCommentQuery())
->setViewer($user) ->setViewer($viewer)
->needHidden(true) ->needHidden(true)
->withRevisionPHIDs(array($revision->getPHID())); ->withRevisionPHIDs(array($revision->getPHID()));
$inlines = $query->execute(); $inlines = $query->execute();
@ -205,7 +201,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
$commit_hashes = array_unique(array_filter($commit_hashes)); $commit_hashes = array_unique(array_filter($commit_hashes));
if ($commit_hashes) { if ($commit_hashes) {
$commits_for_links = id(new DiffusionCommitQuery()) $commits_for_links = id(new DiffusionCommitQuery())
->setViewer($user) ->setViewer($viewer)
->withIdentifiers($commit_hashes) ->withIdentifiers($commit_hashes)
->execute(); ->execute();
$commits_for_links = mpull( $commits_for_links = mpull(
@ -217,7 +213,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
} }
$revision_detail = id(new DifferentialRevisionDetailView()) $revision_detail = id(new DifferentialRevisionDetailView())
->setUser($user) ->setUser($viewer)
->setRevision($revision) ->setRevision($revision)
->setDiff(end($diffs)) ->setDiff(end($diffs))
->setCustomFields($field_list) ->setCustomFields($field_list)
@ -239,7 +235,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
} }
$revision_detail->setActions($actions); $revision_detail->setActions($actions);
$revision_detail->setUser($user); $revision_detail->setUser($viewer);
$revision_detail_box = $revision_detail->render(); $revision_detail_box = $revision_detail->render();
@ -261,7 +257,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
$detail_diffs = mpull($detail_diffs, null, 'getPHID'); $detail_diffs = mpull($detail_diffs, null, 'getPHID');
$buildables = id(new HarbormasterBuildableQuery()) $buildables = id(new HarbormasterBuildableQuery())
->setViewer($user) ->setViewer($viewer)
->withBuildablePHIDs(array_keys($detail_diffs)) ->withBuildablePHIDs(array_keys($detail_diffs))
->withManualBuildables(false) ->withManualBuildables(false)
->needBuilds(true) ->needBuilds(true)
@ -311,7 +307,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
'/differential/changeset/?view=old', '/differential/changeset/?view=old',
'/differential/changeset/?view=new'); '/differential/changeset/?view=new');
$changeset_view->setUser($user); $changeset_view->setUser($viewer);
$changeset_view->setDiff($target); $changeset_view->setDiff($target);
$changeset_view->setRenderingReferences($rendering_references); $changeset_view->setRenderingReferences($rendering_references);
$changeset_view->setVsMap($vs_map); $changeset_view->setVsMap($vs_map);
@ -323,7 +319,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
$changeset_view->setTitle(pht('Diff %s', $target->getID())); $changeset_view->setTitle(pht('Diff %s', $target->getID()));
$diff_history = id(new DifferentialRevisionUpdateHistoryView()) $diff_history = id(new DifferentialRevisionUpdateHistoryView())
->setUser($user) ->setUser($viewer)
->setDiffs($diffs) ->setDiffs($diffs)
->setSelectedVersusDiffID($diff_vs) ->setSelectedVersusDiffID($diff_vs)
->setSelectedDiffID($target->getID()) ->setSelectedDiffID($target->getID())
@ -331,7 +327,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
->setCommitsForLinks($commits_for_links); ->setCommitsForLinks($commits_for_links);
$local_view = id(new DifferentialLocalCommitsView()) $local_view = id(new DifferentialLocalCommitsView())
->setUser($user) ->setUser($viewer)
->setLocalCommits(idx($props, 'local:commits')) ->setLocalCommits(idx($props, 'local:commits'))
->setCommitsForLinks($commits_for_links); ->setCommitsForLinks($commits_for_links);
@ -352,13 +348,13 @@ final class DifferentialRevisionViewController extends DifferentialController {
$toc_view = $this->buildTableOfContents( $toc_view = $this->buildTableOfContents(
$changesets, $changesets,
$visible_changesets, $visible_changesets,
$target->loadCoverageMap($user)); $target->loadCoverageMap($viewer));
$comment_form = null; $comment_form = null;
if (!$viewer_is_anonymous) { if (!$viewer_is_anonymous) {
$draft = id(new PhabricatorDraft())->loadOneWhere( $draft = id(new PhabricatorDraft())->loadOneWhere(
'authorPHID = %s AND draftKey = %s', 'authorPHID = %s AND draftKey = %s',
$user->getPHID(), $viewer->getPHID(),
'differential-comment-'.$revision->getID()); 'differential-comment-'.$revision->getID());
$reviewers = array(); $reviewers = array();
@ -394,7 +390,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
'comment/save/'.$revision->getID().'/'); 'comment/save/'.$revision->getID().'/');
$comment_form->setActionURI($action_uri); $comment_form->setActionURI($action_uri);
$comment_form->setUser($user); $comment_form->setUser($viewer);
$comment_form->setDraft($draft); $comment_form->setDraft($draft);
$comment_form->setReviewers(mpull($reviewers, 'getFullName', 'getPHID')); $comment_form->setReviewers(mpull($reviewers, 'getFullName', 'getPHID'));
$comment_form->setCCs(mpull($ccs, 'getFullName', 'getPHID')); $comment_form->setCCs(mpull($ccs, 'getFullName', 'getPHID'));
@ -461,7 +457,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
// TODO: For now, just use this to get "Login to Comment". // TODO: For now, just use this to get "Login to Comment".
$page_pane->appendChild( $page_pane->appendChild(
id(new PhabricatorApplicationTransactionCommentView()) id(new PhabricatorApplicationTransactionCommentView())
->setUser($user) ->setUser($viewer)
->setRequestURI($request->getRequestURI())); ->setRequestURI($request->getRequestURI()));
} }
@ -476,7 +472,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
$crumbs = $this->buildApplicationCrumbs(); $crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($object_id, '/'.$object_id); $crumbs->addTextCrumb($object_id, '/'.$object_id);
$prefs = $user->loadPreferences(); $prefs = $viewer->loadPreferences();
$pref_filetree = PhabricatorUserPreferences::PREFERENCE_DIFF_FILETREE; $pref_filetree = PhabricatorUserPreferences::PREFERENCE_DIFF_FILETREE;
if ($prefs->getPreference($pref_filetree)) { if ($prefs->getPreference($pref_filetree)) {