From 3af442e4ac94c93eef68b955977c0dd63a4a705a Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 4 Sep 2014 12:51:33 -0700 Subject: [PATCH] Don't require an actor in `PhabricatorFile::attachToObject()` Summary: Ref T6013. A very long time ago, edges were less clearly low-level infrastructure, and some user-aware stuff got built around edge edits. This was kind of a mess and I eventually removed it, during or prior to T5245. The big issue was that control flow was really hard to figure out as things went all the way down to the deepest level of infrastructure and then came back up the stack to events and transactions. The new stuff is more top-down and generally seems a lot easier and cleaner. Consequently, actors are no longer required for edge edits. Remove the parameter. Test Plan: Poked around; ran unit tests. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley, hach-que Maniphest Tasks: T6013 Differential Revision: https://secure.phabricator.com/D10412 --- .../controller/DifferentialRevisionViewController.php | 4 +--- .../diffusion/controller/DiffusionBrowseFileController.php | 1 - .../diffusion/controller/DiffusionCommitController.php | 4 +--- src/applications/files/storage/PhabricatorFile.php | 3 +-- .../files/storage/__tests__/PhabricatorFileTestCase.php | 2 +- src/applications/macro/editor/PhabricatorMacroEditor.php | 2 +- .../controller/PhabricatorPeopleProfilePictureController.php | 2 +- .../phragment/controller/PhragmentPatchController.php | 2 +- .../phragment/controller/PhragmentZIPController.php | 2 +- src/applications/phragment/storage/PhragmentFragment.php | 2 +- 10 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/applications/differential/controller/DifferentialRevisionViewController.php b/src/applications/differential/controller/DifferentialRevisionViewController.php index 2a01005cb7..7a801c72ac 100644 --- a/src/applications/differential/controller/DifferentialRevisionViewController.php +++ b/src/applications/differential/controller/DifferentialRevisionViewController.php @@ -913,9 +913,7 @@ final class DifferentialRevisionViewController extends DifferentialController { )); $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); - $file->attachToObject( - $this->getRequest()->getUser(), - $revision->getPHID()); + $file->attachToObject($revision->getPHID()); unset($unguarded); return $file->getRedirectResponse(); diff --git a/src/applications/diffusion/controller/DiffusionBrowseFileController.php b/src/applications/diffusion/controller/DiffusionBrowseFileController.php index 5c208d929d..a8d11431aa 100644 --- a/src/applications/diffusion/controller/DiffusionBrowseFileController.php +++ b/src/applications/diffusion/controller/DiffusionBrowseFileController.php @@ -881,7 +881,6 @@ final class DiffusionBrowseFileController extends DiffusionBrowseController { $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); $file->attachToObject( - $this->getRequest()->getUser(), $this->getDiffusionRequest()->getRepository()->getPHID()); unset($unguarded); diff --git a/src/applications/diffusion/controller/DiffusionCommitController.php b/src/applications/diffusion/controller/DiffusionCommitController.php index 25d6ea8622..101d1e1fce 100644 --- a/src/applications/diffusion/controller/DiffusionCommitController.php +++ b/src/applications/diffusion/controller/DiffusionCommitController.php @@ -1037,9 +1037,7 @@ final class DiffusionCommitController extends DiffusionController { )); $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); - $file->attachToObject( - $this->getRequest()->getUser(), - $drequest->getRepository()->getPHID()); + $file->attachToObject($drequest->getRepository()->getPHID()); unset($unguarded); return $file->getRedirectResponse(); diff --git a/src/applications/files/storage/PhabricatorFile.php b/src/applications/files/storage/PhabricatorFile.php index a59f1aa95f..4fc4e4761b 100644 --- a/src/applications/files/storage/PhabricatorFile.php +++ b/src/applications/files/storage/PhabricatorFile.php @@ -944,11 +944,10 @@ final class PhabricatorFile extends PhabricatorFileDAO /** * Write the policy edge between this file and some object. * - * @param PhabricatorUser Acting user. * @param phid Object PHID to attach to. * @return this */ - public function attachToObject(PhabricatorUser $actor, $phid) { + public function attachToObject($phid) { $edge_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_FILE; id(new PhabricatorEdgeEditor()) diff --git a/src/applications/files/storage/__tests__/PhabricatorFileTestCase.php b/src/applications/files/storage/__tests__/PhabricatorFileTestCase.php index fe96c0eb50..b8556c0961 100644 --- a/src/applications/files/storage/__tests__/PhabricatorFileTestCase.php +++ b/src/applications/files/storage/__tests__/PhabricatorFileTestCase.php @@ -60,7 +60,7 @@ final class PhabricatorFileTestCase extends PhabricatorTestCase { // Attach the file to the object and test that the association opens a // policy exception for the non-author viewer. - $file->attachToObject($author, $object->getPHID()); + $file->attachToObject($object->getPHID()); // Test the attached file's visibility. $this->assertEqual( diff --git a/src/applications/macro/editor/PhabricatorMacroEditor.php b/src/applications/macro/editor/PhabricatorMacroEditor.php index 5c0025ee79..09d4c99fb4 100644 --- a/src/applications/macro/editor/PhabricatorMacroEditor.php +++ b/src/applications/macro/editor/PhabricatorMacroEditor.php @@ -111,7 +111,7 @@ final class PhabricatorMacroEditor $new_file = idx($files, $new); if ($new_file) { - $new_file->attachToObject($this->requireActor(), $object->getPHID()); + $new_file->attachToObject($object->getPHID()); } break; } diff --git a/src/applications/people/controller/PhabricatorPeopleProfilePictureController.php b/src/applications/people/controller/PhabricatorPeopleProfilePictureController.php index 55cfb8731c..a36b2b4696 100644 --- a/src/applications/people/controller/PhabricatorPeopleProfilePictureController.php +++ b/src/applications/people/controller/PhabricatorPeopleProfilePictureController.php @@ -83,7 +83,7 @@ final class PhabricatorPeopleProfilePictureController $user->setProfileImagePHID(null); } else { $user->setProfileImagePHID($xformed->getPHID()); - $xformed->attachToObject($viewer, $user->getPHID()); + $xformed->attachToObject($user->getPHID()); } $user->save(); return id(new AphrontRedirectResponse())->setURI($profile_uri); diff --git a/src/applications/phragment/controller/PhragmentPatchController.php b/src/applications/phragment/controller/PhragmentPatchController.php index 8d7b497f21..5a04403898 100644 --- a/src/applications/phragment/controller/PhragmentPatchController.php +++ b/src/applications/phragment/controller/PhragmentPatchController.php @@ -94,7 +94,7 @@ final class PhragmentPatchController extends PhragmentController { )); $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); - $result->attachToObject($viewer, $version_b->getFragmentPHID()); + $result->attachToObject($version_b->getFragmentPHID()); unset($unguarded); return id(new AphrontRedirectResponse()) diff --git a/src/applications/phragment/controller/PhragmentZIPController.php b/src/applications/phragment/controller/PhragmentZIPController.php index edc503ee83..574090eede 100644 --- a/src/applications/phragment/controller/PhragmentZIPController.php +++ b/src/applications/phragment/controller/PhragmentZIPController.php @@ -114,7 +114,7 @@ final class PhragmentZIPController extends PhragmentController { )); $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); - $file->attachToObject($viewer, $fragment->getPHID()); + $file->attachToObject($fragment->getPHID()); unset($unguarded); $return = $fragment->getURI(); diff --git a/src/applications/phragment/storage/PhragmentFragment.php b/src/applications/phragment/storage/PhragmentFragment.php index 8ea1ae2401..6d8b3f803c 100644 --- a/src/applications/phragment/storage/PhragmentFragment.php +++ b/src/applications/phragment/storage/PhragmentFragment.php @@ -119,7 +119,7 @@ final class PhragmentFragment extends PhragmentDAO $this->save(); $this->saveTransaction(); - $file->attachToObject($viewer, $version->getPHID()); + $file->attachToObject($version->getPHID()); } /**