From e3daf598fb58a5be9a13b45ff1b730e9670f0d47 Mon Sep 17 00:00:00 2001 From: Chad Little Date: Sat, 2 Apr 2016 14:24:40 +0000 Subject: [PATCH] Moderize Phragment Summary: Swap over to modern components, `newPage` and `handleRequest`. Test Plan: `arc lint` :( Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin, hach-que Differential Revision: https://secure.phabricator.com/D15571 --- .../controller/PhragmentBrowseController.php | 37 ++++++++-------- .../controller/PhragmentCreateController.php | 35 +++++++-------- .../controller/PhragmentHistoryController.php | 37 ++++++++-------- .../controller/PhragmentPatchController.php | 27 +++++------- .../controller/PhragmentPolicyController.php | 35 +++++++-------- .../controller/PhragmentRevertController.php | 26 ++++------- .../PhragmentSnapshotCreateController.php | 35 +++++++-------- .../PhragmentSnapshotDeleteController.php | 19 +++----- .../PhragmentSnapshotPromoteController.php | 43 ++++++++----------- .../PhragmentSnapshotViewController.php | 36 +++++++--------- .../controller/PhragmentUpdateController.php | 35 +++++++-------- .../controller/PhragmentVersionController.php | 40 ++++++++--------- .../controller/PhragmentZIPController.php | 37 ++++++++-------- 13 files changed, 191 insertions(+), 251 deletions(-) diff --git a/src/applications/phragment/controller/PhragmentBrowseController.php b/src/applications/phragment/controller/PhragmentBrowseController.php index 7b0a16cc52..d511835ce9 100644 --- a/src/applications/phragment/controller/PhragmentBrowseController.php +++ b/src/applications/phragment/controller/PhragmentBrowseController.php @@ -2,21 +2,15 @@ final class PhragmentBrowseController extends PhragmentController { - private $dblob; - public function shouldAllowPublic() { return true; } - public function willProcessRequest(array $data) { - $this->dblob = idx($data, 'dblob', ''); - } + public function handleRequest(AphrontRequest $request) { + $viewer = $request->getViewer(); + $dblob = $request->getURIData('dblob'); - public function processRequest() { - $request = $this->getRequest(); - $viewer = $request->getUser(); - - $parents = $this->loadParentFragments($this->dblob); + $parents = $this->loadParentFragments($dblob); if ($parents === null) { return new Aphront404Response(); } @@ -83,16 +77,19 @@ final class PhragmentBrowseController extends PhragmentController { $list->addItem($item); } - return $this->buildApplicationPage( - array( - $crumbs, - $this->renderConfigurationWarningIfRequired(), - $current_box, - $list, - ), - array( - 'title' => pht('Browse Fragments'), - )); + $title = pht('Browse Fragments'); + + $view = array( + $this->renderConfigurationWarningIfRequired(), + $current_box, + $list, + ); + + return $this->newPage() + ->setTitle($title) + ->setCrumbs($crumbs) + ->appendChild($view); + } } diff --git a/src/applications/phragment/controller/PhragmentCreateController.php b/src/applications/phragment/controller/PhragmentCreateController.php index 2a5b54538c..946d7cc332 100644 --- a/src/applications/phragment/controller/PhragmentCreateController.php +++ b/src/applications/phragment/controller/PhragmentCreateController.php @@ -2,18 +2,12 @@ final class PhragmentCreateController extends PhragmentController { - private $dblob; - - public function willProcessRequest(array $data) { - $this->dblob = idx($data, 'dblob', ''); - } - - public function processRequest() { - $request = $this->getRequest(); - $viewer = $request->getUser(); + public function handleRequest(AphrontRequest $request) { + $viewer = $request->getViewer(); + $dblob = $request->getURIData('dblob'); $parent = null; - $parents = $this->loadParentFragments($this->dblob); + $parents = $this->loadParentFragments($dblob); if ($parents === null) { return new Aphront404Response(); } @@ -124,15 +118,18 @@ final class PhragmentCreateController extends PhragmentController { $box->setInfoView($error_view); } - return $this->buildApplicationPage( - array( - $crumbs, - $this->renderConfigurationWarningIfRequired(), - $box, - ), - array( - 'title' => pht('Create Fragment'), - )); + $title = pht('Create Fragments'); + + $view = array( + $this->renderConfigurationWarningIfRequired(), + $box, + ); + + return $this->newPage() + ->setTitle($title) + ->setCrumbs($crumbs) + ->appendChild($view); + } } diff --git a/src/applications/phragment/controller/PhragmentHistoryController.php b/src/applications/phragment/controller/PhragmentHistoryController.php index 72e0000b80..4e16deb43d 100644 --- a/src/applications/phragment/controller/PhragmentHistoryController.php +++ b/src/applications/phragment/controller/PhragmentHistoryController.php @@ -2,21 +2,15 @@ final class PhragmentHistoryController extends PhragmentController { - private $dblob; - public function shouldAllowPublic() { return true; } - public function willProcessRequest(array $data) { - $this->dblob = idx($data, 'dblob', ''); - } + public function handleRequest(AphrontRequest $request) { + $viewer = $request->getViewer(); + $dblob = $request->getURIData('dblob'); - public function processRequest() { - $request = $this->getRequest(); - $viewer = $request->getUser(); - - $parents = $this->loadParentFragments($this->dblob); + $parents = $this->loadParentFragments($dblob); if ($parents === null) { return new Aphront404Response(); } @@ -97,16 +91,19 @@ final class PhragmentHistoryController extends PhragmentController { $first = false; } - return $this->buildApplicationPage( - array( - $crumbs, - $this->renderConfigurationWarningIfRequired(), - $current_box, - $list, - ), - array( - 'title' => pht('Fragment History'), - )); + $title = pht('Fragment History'); + + $view = array( + $this->renderConfigurationWarningIfRequired(), + $current_box, + $list, + ); + + return $this->newPage() + ->setTitle($title) + ->setCrumbs($crumbs) + ->appendChild($view); + } } diff --git a/src/applications/phragment/controller/PhragmentPatchController.php b/src/applications/phragment/controller/PhragmentPatchController.php index 5a04403898..5ad4b6dfec 100644 --- a/src/applications/phragment/controller/PhragmentPatchController.php +++ b/src/applications/phragment/controller/PhragmentPatchController.php @@ -2,28 +2,21 @@ final class PhragmentPatchController extends PhragmentController { - private $aid; - private $bid; - public function shouldAllowPublic() { return true; } - public function willProcessRequest(array $data) { - $this->aid = idx($data, 'aid', 0); - $this->bid = idx($data, 'bid', 0); - } - - public function processRequest() { - $request = $this->getRequest(); - $viewer = $request->getUser(); + public function handleRequest(AphrontRequest $request) { + $viewer = $request->getViewer(); + $aid = $request->getURIData('aid'); + $bid = $request->getURIData('bid'); // If "aid" is "x", then it means the user wants to generate // a patch of an empty file to the version specified by "bid". - $ids = array($this->aid, $this->bid); - if ($this->aid === 'x') { - $ids = array($this->bid); + $ids = array($aid, $bid); + if ($aid === 'x') { + $ids = array($bid); } $versions = id(new PhragmentFragmentVersionQuery()) @@ -32,14 +25,14 @@ final class PhragmentPatchController extends PhragmentController { ->execute(); $version_a = null; - if ($this->aid !== 'x') { - $version_a = idx($versions, $this->aid, null); + if ($aid !== 'x') { + $version_a = idx($versions, $aid, null); if ($version_a === null) { return new Aphront404Response(); } } - $version_b = idx($versions, $this->bid, null); + $version_b = idx($versions, $bid, null); if ($version_b === null) { return new Aphront404Response(); } diff --git a/src/applications/phragment/controller/PhragmentPolicyController.php b/src/applications/phragment/controller/PhragmentPolicyController.php index 700c3edb5b..edcde80990 100644 --- a/src/applications/phragment/controller/PhragmentPolicyController.php +++ b/src/applications/phragment/controller/PhragmentPolicyController.php @@ -2,17 +2,11 @@ final class PhragmentPolicyController extends PhragmentController { - private $dblob; + public function handleRequest(AphrontRequest $request) { + $viewer = $request->getViewer(); + $dblob = $request->getURIData('dblob'); - public function willProcessRequest(array $data) { - $this->dblob = idx($data, 'dblob', ''); - } - - public function processRequest() { - $request = $this->getRequest(); - $viewer = $request->getUser(); - - $parents = $this->loadParentFragments($this->dblob); + $parents = $this->loadParentFragments($dblob); if ($parents === null) { return new Aphront404Response(); } @@ -95,15 +89,18 @@ final class PhragmentPolicyController extends PhragmentController { ->setValidationException(null) ->setForm($form); - return $this->buildApplicationPage( - array( - $crumbs, - $this->renderConfigurationWarningIfRequired(), - $box, - ), - array( - 'title' => pht('Edit Fragment Policies'), - )); + $title = pht('Edit Fragment Policies'); + + $view = array( + $this->renderConfigurationWarningIfRequired(), + $box, + ); + + return $this->newPage() + ->setTitle($title) + ->setCrumbs($crumbs) + ->appendChild($view); + } } diff --git a/src/applications/phragment/controller/PhragmentRevertController.php b/src/applications/phragment/controller/PhragmentRevertController.php index 92da1f27a3..e9d56eb112 100644 --- a/src/applications/phragment/controller/PhragmentRevertController.php +++ b/src/applications/phragment/controller/PhragmentRevertController.php @@ -2,21 +2,14 @@ final class PhragmentRevertController extends PhragmentController { - private $dblob; - private $id; - - public function willProcessRequest(array $data) { - $this->dblob = $data['dblob']; - $this->id = $data['id']; - } - - public function processRequest() { - $request = $this->getRequest(); - $viewer = $request->getUser(); + public function handleRequest(AphrontRequest $request) { + $viewer = $request->getViewer(); + $id = $request->getURIData('id'); + $dblob = $request->getURIData('dblob'); $fragment = id(new PhragmentFragmentQuery()) ->setViewer($viewer) - ->withPaths(array($this->dblob)) + ->withPaths(array($dblob)) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, @@ -30,7 +23,7 @@ final class PhragmentRevertController extends PhragmentController { $version = id(new PhragmentFragmentVersionQuery()) ->setViewer($viewer) ->withFragmentPHIDs(array($fragment->getPHID())) - ->withIDs(array($this->id)) + ->withIDs(array($id)) ->executeOne(); if ($version === null) { return new Aphront404Response(); @@ -58,7 +51,7 @@ final class PhragmentRevertController extends PhragmentController { } return id(new AphrontRedirectResponse()) - ->setURI($this->getApplicationURI('/history/'.$this->dblob)); + ->setURI($this->getApplicationURI('/history/'.$dblob)); } return $this->createDialog($fragment, $version); @@ -68,12 +61,11 @@ final class PhragmentRevertController extends PhragmentController { PhragmentFragment $fragment, PhragmentFragmentVersion $version) { - $request = $this->getRequest(); - $viewer = $request->getUser(); + $viewer = $this->getViewer(); $dialog = id(new AphrontDialogView()) ->setTitle(pht('Really revert this fragment?')) - ->setUser($request->getUser()) + ->setUser($this->getViewer()) ->addSubmitButton(pht('Revert')) ->addCancelButton(pht('Cancel')) ->appendParagraph(pht( diff --git a/src/applications/phragment/controller/PhragmentSnapshotCreateController.php b/src/applications/phragment/controller/PhragmentSnapshotCreateController.php index e135819280..c32be32cd7 100644 --- a/src/applications/phragment/controller/PhragmentSnapshotCreateController.php +++ b/src/applications/phragment/controller/PhragmentSnapshotCreateController.php @@ -2,17 +2,11 @@ final class PhragmentSnapshotCreateController extends PhragmentController { - private $dblob; + public function handleRequest(AphrontRequest $request) { + $viewer = $request->getViewer(); + $dblob = $request->getURIData('dblob'); - public function willProcessRequest(array $data) { - $this->dblob = idx($data, 'dblob', ''); - } - - public function processRequest() { - $request = $this->getRequest(); - $viewer = $request->getUser(); - - $parents = $this->loadParentFragments($this->dblob); + $parents = $this->loadParentFragments($dblob); if ($parents === null) { return new Aphront404Response(); } @@ -159,15 +153,18 @@ final class PhragmentSnapshotCreateController extends PhragmentController { ->setFormErrors($errors) ->setForm($form); - return $this->buildApplicationPage( - array( - $crumbs, - $this->renderConfigurationWarningIfRequired(), - $box, - ), - array( - 'title' => pht('Create Fragment'), - )); + $title = pht('Create Snapshot'); + + $view = array( + $this->renderConfigurationWarningIfRequired(), + $box, + ); + + return $this->newPage() + ->setTitle($title) + ->setCrumbs($crumbs) + ->appendChild($view); + } } diff --git a/src/applications/phragment/controller/PhragmentSnapshotDeleteController.php b/src/applications/phragment/controller/PhragmentSnapshotDeleteController.php index 715280a2c2..8f112585d0 100644 --- a/src/applications/phragment/controller/PhragmentSnapshotDeleteController.php +++ b/src/applications/phragment/controller/PhragmentSnapshotDeleteController.php @@ -2,15 +2,9 @@ final class PhragmentSnapshotDeleteController extends PhragmentController { - private $id; - - public function willProcessRequest(array $data) { - $this->id = $data['id']; - } - - public function processRequest() { - $request = $this->getRequest(); - $viewer = $request->getUser(); + public function handleRequest(AphrontRequest $request) { + $viewer = $request->getViewer(); + $id = $request->getURIData('id'); $snapshot = id(new PhragmentSnapshotQuery()) ->setViewer($viewer) @@ -18,7 +12,7 @@ final class PhragmentSnapshotDeleteController extends PhragmentController { PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, )) - ->withIDs(array($this->id)) + ->withIDs(array($id)) ->executeOne(); if ($snapshot === null) { return new Aphront404Response(); @@ -37,12 +31,11 @@ final class PhragmentSnapshotDeleteController extends PhragmentController { } public function createDialog() { - $request = $this->getRequest(); - $viewer = $request->getUser(); + $viewer = $this->getViewer(); $dialog = id(new AphrontDialogView()) ->setTitle(pht('Really delete this snapshot?')) - ->setUser($request->getUser()) + ->setUser($this->getViewer()) ->addSubmitButton(pht('Delete')) ->addCancelButton(pht('Cancel')) ->appendParagraph(pht( diff --git a/src/applications/phragment/controller/PhragmentSnapshotPromoteController.php b/src/applications/phragment/controller/PhragmentSnapshotPromoteController.php index 18d7df6a5a..981d139742 100644 --- a/src/applications/phragment/controller/PhragmentSnapshotPromoteController.php +++ b/src/applications/phragment/controller/PhragmentSnapshotPromoteController.php @@ -2,32 +2,26 @@ final class PhragmentSnapshotPromoteController extends PhragmentController { - private $dblob; - private $id; private $targetSnapshot; private $targetFragment; private $snapshots; private $options; - public function willProcessRequest(array $data) { - $this->dblob = idx($data, 'dblob', null); - $this->id = idx($data, 'id', null); - } - - public function processRequest() { - $request = $this->getRequest(); - $viewer = $request->getUser(); + public function handleRequest(AphrontRequest $request) { + $viewer = $request->getViewer(); + $id = $request->getURIData('id'); + $dblob = $request->getURIData('dblob'); // When the user is promoting a snapshot to the latest version, the // identifier is a fragment path. - if ($this->dblob !== null) { + if ($dblob !== null) { $this->targetFragment = id(new PhragmentFragmentQuery()) ->setViewer($viewer) ->requireCapabilities(array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, )) - ->withPaths(array($this->dblob)) + ->withPaths(array($dblob)) ->executeOne(); if ($this->targetFragment === null) { return new Aphront404Response(); @@ -41,14 +35,14 @@ final class PhragmentSnapshotPromoteController extends PhragmentController { // When the user is promoting a snapshot to another snapshot, the // identifier is another snapshot ID. - if ($this->id !== null) { + if ($id !== null) { $this->targetSnapshot = id(new PhragmentSnapshotQuery()) ->setViewer($viewer) ->requireCapabilities(array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, )) - ->withIDs(array($this->id)) + ->withIDs(array($id)) ->executeOne(); if ($this->targetSnapshot === null) { return new Aphront404Response(); @@ -72,8 +66,8 @@ final class PhragmentSnapshotPromoteController extends PhragmentController { $this->snapshots, 'getName', 'getID'); - if ($this->id !== null) { - unset($this->options[$this->id]); + if ($id !== null) { + unset($this->options[$id]); } // If there's no options, show a dialog telling the @@ -84,7 +78,7 @@ final class PhragmentSnapshotPromoteController extends PhragmentController { ->setTitle(pht('No snapshots to promote')) ->appendParagraph(pht( 'There are no snapshots available to promote.')) - ->setUser($request->getUser()) + ->setUser($this->getViewer()) ->addCancelButton(pht('Cancel'))); } @@ -108,7 +102,7 @@ final class PhragmentSnapshotPromoteController extends PhragmentController { $child->delete(); } - if ($this->id === null) { + if ($id === null) { // The user is promoting the snapshot to the latest version. $children = id(new PhragmentFragmentQuery()) ->setViewer($viewer) @@ -150,7 +144,7 @@ final class PhragmentSnapshotPromoteController extends PhragmentController { } $snapshot->saveTransaction(); - if ($this->id === null) { + if ($id === null) { return id(new AphrontRedirectResponse()) ->setURI($this->targetFragment->getURI()); } else { @@ -159,20 +153,19 @@ final class PhragmentSnapshotPromoteController extends PhragmentController { } } - return $this->createDialog(); + return $this->createDialog($id); } - public function createDialog() { - $request = $this->getRequest(); - $viewer = $request->getUser(); + public function createDialog($id) { + $viewer = $this->getViewer(); $dialog = id(new AphrontDialogView()) ->setTitle(pht('Promote which snapshot?')) - ->setUser($request->getUser()) + ->setUser($this->getViewer()) ->addSubmitButton(pht('Promote')) ->addCancelButton(pht('Cancel')); - if ($this->id === null) { + if ($id === null) { // The user is promoting a snapshot to the latest version. $dialog->appendParagraph(pht( 'Select the snapshot you want to promote to the latest version:')); diff --git a/src/applications/phragment/controller/PhragmentSnapshotViewController.php b/src/applications/phragment/controller/PhragmentSnapshotViewController.php index fe499fffa1..052b5036fb 100644 --- a/src/applications/phragment/controller/PhragmentSnapshotViewController.php +++ b/src/applications/phragment/controller/PhragmentSnapshotViewController.php @@ -2,23 +2,17 @@ final class PhragmentSnapshotViewController extends PhragmentController { - private $id; - public function shouldAllowPublic() { return true; } - public function willProcessRequest(array $data) { - $this->id = idx($data, 'id', ''); - } - - public function processRequest() { - $request = $this->getRequest(); - $viewer = $request->getUser(); + public function handleRequest(AphrontRequest $request) { + $viewer = $request->getViewer(); + $id = $request->getURIData('id'); $snapshot = id(new PhragmentSnapshotQuery()) ->setViewer($viewer) - ->withIDs(array($this->id)) + ->withIDs(array($id)) ->executeOne(); if ($snapshot === null) { return new Aphront404Response(); @@ -71,16 +65,18 @@ final class PhragmentSnapshotViewController extends PhragmentController { $list->addItem($item); } - return $this->buildApplicationPage( - array( - $crumbs, - $this->renderConfigurationWarningIfRequired(), - $box, - $list, - ), - array( - 'title' => pht('View Snapshot'), - )); + $title = pht('View Snapshot'); + + $view = array( + $this->renderConfigurationWarningIfRequired(), + $box, + $list, + ); + + return $this->newPage() + ->setTitle($title) + ->setCrumbs($crumbs) + ->appendChild($view); } protected function createSnapshotView($snapshot) { diff --git a/src/applications/phragment/controller/PhragmentUpdateController.php b/src/applications/phragment/controller/PhragmentUpdateController.php index 1b8d10e91f..7fb91ccd4e 100644 --- a/src/applications/phragment/controller/PhragmentUpdateController.php +++ b/src/applications/phragment/controller/PhragmentUpdateController.php @@ -2,17 +2,11 @@ final class PhragmentUpdateController extends PhragmentController { - private $dblob; + public function handleRequest(AphrontRequest $request) { + $viewer = $request->getViewer(); + $dblob = $request->getURIData('dblob'); - public function willProcessRequest(array $data) { - $this->dblob = idx($data, 'dblob', ''); - } - - public function processRequest() { - $request = $this->getRequest(); - $viewer = $request->getUser(); - - $parents = $this->loadParentFragments($this->dblob); + $parents = $this->loadParentFragments($dblob); if ($parents === null) { return new Aphront404Response(); } @@ -69,15 +63,18 @@ final class PhragmentUpdateController extends PhragmentController { ->setValidationException(null) ->setForm($form); - return $this->buildApplicationPage( - array( - $crumbs, - $this->renderConfigurationWarningIfRequired(), - $box, - ), - array( - 'title' => pht('Update Fragment'), - )); + $title = pht('Update Fragment'); + + $view = array( + $this->renderConfigurationWarningIfRequired(), + $box, + ); + + return $this->newPage() + ->setTitle($title) + ->setCrumbs($crumbs) + ->appendChild($view); + } } diff --git a/src/applications/phragment/controller/PhragmentVersionController.php b/src/applications/phragment/controller/PhragmentVersionController.php index 29b920a4e5..2b1ae2bdf0 100644 --- a/src/applications/phragment/controller/PhragmentVersionController.php +++ b/src/applications/phragment/controller/PhragmentVersionController.php @@ -2,23 +2,17 @@ final class PhragmentVersionController extends PhragmentController { - private $id; - public function shouldAllowPublic() { return true; } - public function willProcessRequest(array $data) { - $this->id = idx($data, 'id', 0); - } - - public function processRequest() { - $request = $this->getRequest(); - $viewer = $request->getUser(); + public function handleRequest(AphrontRequest $request) { + $viewer = $request->getViewer(); + $id = $request->getURIData('id'); $version = id(new PhragmentFragmentVersionQuery()) ->setViewer($viewer) - ->withIDs(array($this->id)) + ->withIDs(array($id)) ->executeOne(); if ($version === null) { return new Aphront404Response(); @@ -71,23 +65,23 @@ final class PhragmentVersionController extends PhragmentController { ->setHeader($header) ->addPropertyList($properties); - return $this->buildApplicationPage( - array( - $crumbs, - $this->renderConfigurationWarningIfRequired(), - $box, - $this->renderPreviousVersionList($version), - ), - array( - 'title' => pht('View Version'), - )); + $title = pht('View Version'); + + $view = array( + $this->renderConfigurationWarningIfRequired(), + $box, + $this->renderPreviousVersionList($version), + ); + + return $this->newPage() + ->setTitle($title) + ->setCrumbs($crumbs) + ->appendChild($view); } private function renderPreviousVersionList( PhragmentFragmentVersion $version) { - - $request = $this->getRequest(); - $viewer = $request->getUser(); + $viewer = $this->getViewer(); $previous_versions = id(new PhragmentFragmentVersionQuery()) ->setViewer($viewer) diff --git a/src/applications/phragment/controller/PhragmentZIPController.php b/src/applications/phragment/controller/PhragmentZIPController.php index 0de9f4d344..75d464d9c8 100644 --- a/src/applications/phragment/controller/PhragmentZIPController.php +++ b/src/applications/phragment/controller/PhragmentZIPController.php @@ -2,35 +2,28 @@ final class PhragmentZIPController extends PhragmentController { - private $dblob; - private $snapshot; - private $snapshotCache; public function shouldAllowPublic() { return true; } - public function willProcessRequest(array $data) { - $this->dblob = idx($data, 'dblob', ''); - $this->snapshot = idx($data, 'snapshot', null); - } + public function handleRequest(AphrontRequest $request) { + $viewer = $request->getViewer(); + $dblob = $request->getURIData('dblob'); + $snapshot = $request->getURIData('snapshot'); - public function processRequest() { - $request = $this->getRequest(); - $viewer = $request->getUser(); - - $parents = $this->loadParentFragments($this->dblob); + $parents = $this->loadParentFragments($dblob); if ($parents === null) { return new Aphront404Response(); } $fragment = idx($parents, count($parents) - 1, null); - if ($this->snapshot !== null) { + if ($snapshot !== null) { $snapshot = id(new PhragmentSnapshotQuery()) ->setViewer($viewer) ->withPrimaryFragmentPHIDs(array($fragment->getPHID())) - ->withNames(array($this->snapshot)) + ->withNames(array($snapshot)) ->executeOne(); if ($snapshot === null) { return new Aphront404Response(); @@ -63,7 +56,7 @@ final class PhragmentZIPController extends PhragmentController { $dialog->setTitle(pht('ZIP Extension Not Installed')); $dialog->appendParagraph($inst); - $dialog->addCancelButton('/phragment/browse/'.$this->dblob); + $dialog->addCancelButton('/phragment/browse/'.$dblob); return id(new AphrontDialogResponse())->setDialog($dialog); } @@ -71,7 +64,8 @@ final class PhragmentZIPController extends PhragmentController { throw new Exception(pht('Unable to create ZIP archive!')); } - $mappings = $this->getFragmentMappings($fragment, $fragment->getPath()); + $mappings = $this->getFragmentMappings( + $fragment, $fragment->getPath(), $snapshot); $phids = array(); foreach ($mappings as $path => $file_phid) { @@ -130,14 +124,17 @@ final class PhragmentZIPController extends PhragmentController { /** * Returns a list of mappings like array('some/path.txt' => 'file PHID'); */ - private function getFragmentMappings(PhragmentFragment $current, $base_path) { + private function getFragmentMappings( + PhragmentFragment $current, + $base_path, + $snapshot) { $mappings = $current->getFragmentMappings( $this->getRequest()->getUser(), $base_path); $result = array(); foreach ($mappings as $path => $fragment) { - $version = $this->getVersion($fragment); + $version = $this->getVersion($fragment, $snapshot); if ($version !== null) { $result[$path] = $version->getFilePHID(); } @@ -145,8 +142,8 @@ final class PhragmentZIPController extends PhragmentController { return $result; } - private function getVersion($fragment) { - if ($this->snapshot === null) { + private function getVersion($fragment, $snapshot) { + if ($snapshot === null) { return $fragment->getLatestVersion(); } else { return idx($this->snapshotCache, $fragment->getPHID(), null);