mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-07 12:28:28 +01:00
Reduce PhabricatorUser::getOmnipotentUser calls by adding a getViewer method to PhbaricatorDestructionEngine
Summary: Fixes T6956. Before this change, we called PhabricatorUser::getOmnipotentUser in the various delete methods to query the data. Now, we use $engine->getViewer(), since its always a good thing to have less calls to PhabricatorUser::getOmnipotentUser thrown around the codebase. I used the "codemod" tool to audit the existing calls to PhabricatorDestructorEngine (all of them) so ostensibly this gets all the spots. If I missed something though, its still going to work, so this change is very low risk. Test Plan: ./bin/remove destroy P1; visit P1 and get a 404 Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T6956 Differential Revision: https://secure.phabricator.com/D12866
This commit is contained in:
parent
b6733e4a86
commit
3ef0721ada
10 changed files with 14 additions and 10 deletions
|
@ -240,7 +240,7 @@ final class AlmanacDevice
|
||||||
PhabricatorDestructionEngine $engine) {
|
PhabricatorDestructionEngine $engine) {
|
||||||
|
|
||||||
$interfaces = id(new AlmanacInterfaceQuery())
|
$interfaces = id(new AlmanacInterfaceQuery())
|
||||||
->setViewer(PhabricatorUser::getOmnipotentUser())
|
->setViewer($engine->getViewer())
|
||||||
->withDevicePHIDs(array($this->getPHID()))
|
->withDevicePHIDs(array($this->getPHID()))
|
||||||
->execute();
|
->execute();
|
||||||
foreach ($interfaces as $interface) {
|
foreach ($interfaces as $interface) {
|
||||||
|
|
|
@ -119,7 +119,7 @@ final class AlmanacInterface
|
||||||
PhabricatorDestructionEngine $engine) {
|
PhabricatorDestructionEngine $engine) {
|
||||||
|
|
||||||
$bindings = id(new AlmanacBindingQuery())
|
$bindings = id(new AlmanacBindingQuery())
|
||||||
->setViewer($this->getViewer())
|
->setViewer($engine->getViewer())
|
||||||
->withInterfacePHIDs(array($this->getPHID()))
|
->withInterfacePHIDs(array($this->getPHID()))
|
||||||
->execute();
|
->execute();
|
||||||
foreach ($bindings as $binding) {
|
foreach ($bindings as $binding) {
|
||||||
|
|
|
@ -103,7 +103,7 @@ final class AlmanacNetwork
|
||||||
PhabricatorDestructionEngine $engine) {
|
PhabricatorDestructionEngine $engine) {
|
||||||
|
|
||||||
$interfaces = id(new AlmanacInterfaceQuery())
|
$interfaces = id(new AlmanacInterfaceQuery())
|
||||||
->setViewer(PhabricatorUser::getOmnipotentUser())
|
->setViewer($engine->getViewer())
|
||||||
->withNetworkPHIDs(array($this->getPHID()))
|
->withNetworkPHIDs(array($this->getPHID()))
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
|
|
|
@ -221,7 +221,7 @@ final class AlmanacService
|
||||||
PhabricatorDestructionEngine $engine) {
|
PhabricatorDestructionEngine $engine) {
|
||||||
|
|
||||||
$bindings = id(new AlmanacBindingQuery())
|
$bindings = id(new AlmanacBindingQuery())
|
||||||
->setViewer(PhabricatorUser::getOmnipotentUser())
|
->setViewer($engine->getViewer())
|
||||||
->withServicePHIDs(array($this->getPHID()))
|
->withServicePHIDs(array($this->getPHID()))
|
||||||
->execute();
|
->execute();
|
||||||
foreach ($bindings as $binding) {
|
foreach ($bindings as $binding) {
|
||||||
|
|
|
@ -550,7 +550,7 @@ final class DifferentialRevision extends DifferentialDAO
|
||||||
|
|
||||||
$this->openTransaction();
|
$this->openTransaction();
|
||||||
$diffs = id(new DifferentialDiffQuery())
|
$diffs = id(new DifferentialDiffQuery())
|
||||||
->setViewer(PhabricatorUser::getOmnipotentUser())
|
->setViewer($engine->getViewer())
|
||||||
->withRevisionIDs(array($this->getID()))
|
->withRevisionIDs(array($this->getID()))
|
||||||
->execute();
|
->execute();
|
||||||
foreach ($diffs as $diff) {
|
foreach ($diffs as $diff) {
|
||||||
|
|
|
@ -91,7 +91,7 @@ final class DivinerLiveBook extends DivinerDAO
|
||||||
|
|
||||||
$this->openTransaction();
|
$this->openTransaction();
|
||||||
$atoms = id(new DivinerAtomQuery())
|
$atoms = id(new DivinerAtomQuery())
|
||||||
->setViewer(PhabricatorUser::getOmnipotentUser())
|
->setViewer($engine->getViewer())
|
||||||
->withBookPHIDs(array($this->getPHID()))
|
->withBookPHIDs(array($this->getPHID()))
|
||||||
->withIncludeGhosts(true)
|
->withIncludeGhosts(true)
|
||||||
->withIncludeUndocumentable(true)
|
->withIncludeUndocumentable(true)
|
||||||
|
|
|
@ -104,8 +104,9 @@ final class PhabricatorFileTransformController
|
||||||
}
|
}
|
||||||
|
|
||||||
private function destroyTransform(PhabricatorTransformedFile $xform) {
|
private function destroyTransform(PhabricatorTransformedFile $xform) {
|
||||||
|
$engine = new PhabricatorDestructionEngine();
|
||||||
$file = id(new PhabricatorFileQuery())
|
$file = id(new PhabricatorFileQuery())
|
||||||
->setViewer(PhabricatorUser::getOmnipotentUser())
|
->setViewer($engine->getViewer())
|
||||||
->withPHIDs(array($xform->getTransformedPHID()))
|
->withPHIDs(array($xform->getTransformedPHID()))
|
||||||
->executeOne();
|
->executeOne();
|
||||||
|
|
||||||
|
@ -114,7 +115,6 @@ final class PhabricatorFileTransformController
|
||||||
if (!$file) {
|
if (!$file) {
|
||||||
$xform->delete();
|
$xform->delete();
|
||||||
} else {
|
} else {
|
||||||
$engine = new PhabricatorDestructionEngine();
|
|
||||||
$engine->destroyObject($file);
|
$engine->destroyObject($file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ final class PhabricatorFileChunk extends PhabricatorFileDAO
|
||||||
$data_phid = $this->getDataFilePHID();
|
$data_phid = $this->getDataFilePHID();
|
||||||
if ($data_phid) {
|
if ($data_phid) {
|
||||||
$data_file = id(new PhabricatorFileQuery())
|
$data_file = id(new PhabricatorFileQuery())
|
||||||
->setViewer(PhabricatorUser::getOmnipotentUser())
|
->setViewer($engine->getViewer())
|
||||||
->withPHIDs(array($data_phid))
|
->withPHIDs(array($data_phid))
|
||||||
->executeOne();
|
->executeOne();
|
||||||
if ($data_file) {
|
if ($data_file) {
|
||||||
|
|
|
@ -172,7 +172,7 @@ final class PhabricatorPaste extends PhabricatorPasteDAO
|
||||||
|
|
||||||
if ($this->filePHID) {
|
if ($this->filePHID) {
|
||||||
$file = id(new PhabricatorFileQuery())
|
$file = id(new PhabricatorFileQuery())
|
||||||
->setViewer(PhabricatorUser::getOmnipotentUser())
|
->setViewer($engine->getViewer())
|
||||||
->withPHIDs(array($this->filePHID))
|
->withPHIDs(array($this->filePHID))
|
||||||
->executeOne();
|
->executeOne();
|
||||||
if ($file) {
|
if ($file) {
|
||||||
|
|
|
@ -4,6 +4,10 @@ final class PhabricatorDestructionEngine extends Phobject {
|
||||||
|
|
||||||
private $rootLogID;
|
private $rootLogID;
|
||||||
|
|
||||||
|
public function getViewer() {
|
||||||
|
return PhabricatorUser::getOmnipotentUser();
|
||||||
|
}
|
||||||
|
|
||||||
public function destroyObject(PhabricatorDestructibleInterface $object) {
|
public function destroyObject(PhabricatorDestructibleInterface $object) {
|
||||||
$log = id(new PhabricatorSystemDestructionLog())
|
$log = id(new PhabricatorSystemDestructionLog())
|
||||||
->setEpoch(time())
|
->setEpoch(time())
|
||||||
|
|
Loading…
Add table
Reference in a new issue