1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-19 03:01:11 +01:00

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
This commit is contained in:
epriestley 2014-09-04 12:51:33 -07:00
parent 8038af4bd5
commit 3af442e4ac
10 changed files with 9 additions and 15 deletions

View file

@ -913,9 +913,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
)); ));
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
$file->attachToObject( $file->attachToObject($revision->getPHID());
$this->getRequest()->getUser(),
$revision->getPHID());
unset($unguarded); unset($unguarded);
return $file->getRedirectResponse(); return $file->getRedirectResponse();

View file

@ -881,7 +881,6 @@ final class DiffusionBrowseFileController extends DiffusionBrowseController {
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
$file->attachToObject( $file->attachToObject(
$this->getRequest()->getUser(),
$this->getDiffusionRequest()->getRepository()->getPHID()); $this->getDiffusionRequest()->getRepository()->getPHID());
unset($unguarded); unset($unguarded);

View file

@ -1037,9 +1037,7 @@ final class DiffusionCommitController extends DiffusionController {
)); ));
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
$file->attachToObject( $file->attachToObject($drequest->getRepository()->getPHID());
$this->getRequest()->getUser(),
$drequest->getRepository()->getPHID());
unset($unguarded); unset($unguarded);
return $file->getRedirectResponse(); return $file->getRedirectResponse();

View file

@ -944,11 +944,10 @@ final class PhabricatorFile extends PhabricatorFileDAO
/** /**
* Write the policy edge between this file and some object. * Write the policy edge between this file and some object.
* *
* @param PhabricatorUser Acting user.
* @param phid Object PHID to attach to. * @param phid Object PHID to attach to.
* @return this * @return this
*/ */
public function attachToObject(PhabricatorUser $actor, $phid) { public function attachToObject($phid) {
$edge_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_FILE; $edge_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_FILE;
id(new PhabricatorEdgeEditor()) id(new PhabricatorEdgeEditor())

View file

@ -60,7 +60,7 @@ final class PhabricatorFileTestCase extends PhabricatorTestCase {
// Attach the file to the object and test that the association opens a // Attach the file to the object and test that the association opens a
// policy exception for the non-author viewer. // policy exception for the non-author viewer.
$file->attachToObject($author, $object->getPHID()); $file->attachToObject($object->getPHID());
// Test the attached file's visibility. // Test the attached file's visibility.
$this->assertEqual( $this->assertEqual(

View file

@ -111,7 +111,7 @@ final class PhabricatorMacroEditor
$new_file = idx($files, $new); $new_file = idx($files, $new);
if ($new_file) { if ($new_file) {
$new_file->attachToObject($this->requireActor(), $object->getPHID()); $new_file->attachToObject($object->getPHID());
} }
break; break;
} }

View file

@ -83,7 +83,7 @@ final class PhabricatorPeopleProfilePictureController
$user->setProfileImagePHID(null); $user->setProfileImagePHID(null);
} else { } else {
$user->setProfileImagePHID($xformed->getPHID()); $user->setProfileImagePHID($xformed->getPHID());
$xformed->attachToObject($viewer, $user->getPHID()); $xformed->attachToObject($user->getPHID());
} }
$user->save(); $user->save();
return id(new AphrontRedirectResponse())->setURI($profile_uri); return id(new AphrontRedirectResponse())->setURI($profile_uri);

View file

@ -94,7 +94,7 @@ final class PhragmentPatchController extends PhragmentController {
)); ));
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
$result->attachToObject($viewer, $version_b->getFragmentPHID()); $result->attachToObject($version_b->getFragmentPHID());
unset($unguarded); unset($unguarded);
return id(new AphrontRedirectResponse()) return id(new AphrontRedirectResponse())

View file

@ -114,7 +114,7 @@ final class PhragmentZIPController extends PhragmentController {
)); ));
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
$file->attachToObject($viewer, $fragment->getPHID()); $file->attachToObject($fragment->getPHID());
unset($unguarded); unset($unguarded);
$return = $fragment->getURI(); $return = $fragment->getURI();

View file

@ -119,7 +119,7 @@ final class PhragmentFragment extends PhragmentDAO
$this->save(); $this->save();
$this->saveTransaction(); $this->saveTransaction();
$file->attachToObject($viewer, $version->getPHID()); $file->attachToObject($version->getPHID());
} }
/** /**