Make Drydock more broadly aware of policies
Summary: Ref T2015. Moves a bunch of raw object loads into modern policy-aware queries. Also straightens out the Log and Lease policies a little bit: there are legitimate states where these objects are not attached to a resource (particularly, while a lease is being acquired). Handle these more gracefully. Test Plan: Lint / browsed stuff. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T2015 Differential Revision: https://secure.phabricator.com/D7836
This commit is contained in:
@@ -10,9 +10,12 @@ final class DrydockResourceViewController extends DrydockResourceController {
|
||||
|
||||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
$viewer = $request->getUser();
|
||||
|
||||
$resource = id(new DrydockResource())->load($this->id);
|
||||
$resource = id(new DrydockResourceQuery())
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($this->id))
|
||||
->executeOne();
|
||||
if (!$resource) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
@@ -29,7 +32,7 @@ final class DrydockResourceViewController extends DrydockResourceController {
|
||||
$resource_uri = $this->getApplicationURI($resource_uri);
|
||||
|
||||
$leases = id(new DrydockLeaseQuery())
|
||||
->setViewer($user)
|
||||
->setViewer($viewer)
|
||||
->withResourceIDs(array($resource->getID()))
|
||||
->execute();
|
||||
|
||||
@@ -41,7 +44,7 @@ final class DrydockResourceViewController extends DrydockResourceController {
|
||||
$pager->setOffset($request->getInt('offset'));
|
||||
|
||||
$logs = id(new DrydockLogQuery())
|
||||
->setViewer($user)
|
||||
->setViewer($viewer)
|
||||
->withResourceIDs(array($resource->getID()))
|
||||
->executeWithOffsetPager($pager);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user