mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-11 07:11:04 +01:00
Make Harbormaster objects destructible
Summary: Ref T13114. See PHI511. Ref T13072. This makes Buildables, Builds, Targets and Artifacts destructible with `bin/remove destroy`. This might not be totally exhaustive. In particular: - File artifacts won't destroy the file. This is sort of okay because file artifacts are currently just a file reference, but probably shouldn't be how things work in the long term. - `BuildCommand` doesn't get cleaned up, but `BuildMessage` does on `Build`. See T13072 for more. Test Plan: Used `bin/remove destroy` to nuke a bunch of builds, buildables, etc. Loaded stuff in the web UI and it all looked like it got nuked properly. Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13114, T13072 Differential Revision: https://secure.phabricator.com/D19269
This commit is contained in:
parent
7915445543
commit
7f9a9bc800
6 changed files with 162 additions and 9 deletions
|
@ -6525,6 +6525,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorApplicationTransactionInterface',
|
'PhabricatorApplicationTransactionInterface',
|
||||||
'PhabricatorPolicyInterface',
|
'PhabricatorPolicyInterface',
|
||||||
'PhabricatorConduitResultInterface',
|
'PhabricatorConduitResultInterface',
|
||||||
|
'PhabricatorDestructibleInterface',
|
||||||
),
|
),
|
||||||
'HarbormasterBuildAbortedException' => 'Exception',
|
'HarbormasterBuildAbortedException' => 'Exception',
|
||||||
'HarbormasterBuildActionController' => 'HarbormasterController',
|
'HarbormasterBuildActionController' => 'HarbormasterController',
|
||||||
|
@ -6532,6 +6533,7 @@ phutil_register_library_map(array(
|
||||||
'HarbormasterBuildArtifact' => array(
|
'HarbormasterBuildArtifact' => array(
|
||||||
'HarbormasterDAO',
|
'HarbormasterDAO',
|
||||||
'PhabricatorPolicyInterface',
|
'PhabricatorPolicyInterface',
|
||||||
|
'PhabricatorDestructibleInterface',
|
||||||
),
|
),
|
||||||
'HarbormasterBuildArtifactPHIDType' => 'PhabricatorPHIDType',
|
'HarbormasterBuildArtifactPHIDType' => 'PhabricatorPHIDType',
|
||||||
'HarbormasterBuildArtifactQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
'HarbormasterBuildArtifactQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||||
|
@ -6564,6 +6566,7 @@ phutil_register_library_map(array(
|
||||||
'HarbormasterBuildMessage' => array(
|
'HarbormasterBuildMessage' => array(
|
||||||
'HarbormasterDAO',
|
'HarbormasterDAO',
|
||||||
'PhabricatorPolicyInterface',
|
'PhabricatorPolicyInterface',
|
||||||
|
'PhabricatorDestructibleInterface',
|
||||||
),
|
),
|
||||||
'HarbormasterBuildMessageQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
'HarbormasterBuildMessageQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||||
'HarbormasterBuildPHIDType' => 'PhabricatorPHIDType',
|
'HarbormasterBuildPHIDType' => 'PhabricatorPHIDType',
|
||||||
|
@ -6614,6 +6617,7 @@ phutil_register_library_map(array(
|
||||||
'HarbormasterBuildTarget' => array(
|
'HarbormasterBuildTarget' => array(
|
||||||
'HarbormasterDAO',
|
'HarbormasterDAO',
|
||||||
'PhabricatorPolicyInterface',
|
'PhabricatorPolicyInterface',
|
||||||
|
'PhabricatorDestructibleInterface',
|
||||||
),
|
),
|
||||||
'HarbormasterBuildTargetPHIDType' => 'PhabricatorPHIDType',
|
'HarbormasterBuildTargetPHIDType' => 'PhabricatorPHIDType',
|
||||||
'HarbormasterBuildTargetQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
'HarbormasterBuildTargetQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||||
|
@ -6628,6 +6632,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorApplicationTransactionInterface',
|
'PhabricatorApplicationTransactionInterface',
|
||||||
'PhabricatorPolicyInterface',
|
'PhabricatorPolicyInterface',
|
||||||
'HarbormasterBuildableInterface',
|
'HarbormasterBuildableInterface',
|
||||||
|
'PhabricatorDestructibleInterface',
|
||||||
),
|
),
|
||||||
'HarbormasterBuildableActionController' => 'HarbormasterController',
|
'HarbormasterBuildableActionController' => 'HarbormasterController',
|
||||||
'HarbormasterBuildableListController' => 'HarbormasterController',
|
'HarbormasterBuildableListController' => 'HarbormasterController',
|
||||||
|
|
|
@ -6,8 +6,11 @@
|
||||||
* conditions where we receive a message before a build plan is ready to
|
* conditions where we receive a message before a build plan is ready to
|
||||||
* accept it.
|
* accept it.
|
||||||
*/
|
*/
|
||||||
final class HarbormasterBuildMessage extends HarbormasterDAO
|
final class HarbormasterBuildMessage
|
||||||
implements PhabricatorPolicyInterface {
|
extends HarbormasterDAO
|
||||||
|
implements
|
||||||
|
PhabricatorPolicyInterface,
|
||||||
|
PhabricatorDestructibleInterface {
|
||||||
|
|
||||||
protected $authorPHID;
|
protected $authorPHID;
|
||||||
protected $receiverPHID;
|
protected $receiverPHID;
|
||||||
|
@ -74,4 +77,13 @@ final class HarbormasterBuildMessage extends HarbormasterDAO
|
||||||
return pht('Build messages have the same policies as their receivers.');
|
return pht('Build messages have the same policies as their receivers.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* -( PhabricatorDestructibleInterface )----------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
public function destroyObjectPermanently(
|
||||||
|
PhabricatorDestructionEngine $engine) {
|
||||||
|
$this->delete();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class HarbormasterBuildable extends HarbormasterDAO
|
final class HarbormasterBuildable
|
||||||
|
extends HarbormasterDAO
|
||||||
implements
|
implements
|
||||||
PhabricatorApplicationTransactionInterface,
|
PhabricatorApplicationTransactionInterface,
|
||||||
PhabricatorPolicyInterface,
|
PhabricatorPolicyInterface,
|
||||||
HarbormasterBuildableInterface {
|
HarbormasterBuildableInterface,
|
||||||
|
PhabricatorDestructibleInterface {
|
||||||
|
|
||||||
protected $buildablePHID;
|
protected $buildablePHID;
|
||||||
protected $containerPHID;
|
protected $containerPHID;
|
||||||
|
@ -340,4 +342,32 @@ final class HarbormasterBuildable extends HarbormasterDAO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* -( PhabricatorDestructibleInterface )----------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
public function destroyObjectPermanently(
|
||||||
|
PhabricatorDestructionEngine $engine) {
|
||||||
|
$viewer = $engine->getViewer();
|
||||||
|
|
||||||
|
$this->openTransaction();
|
||||||
|
$builds = id(new HarbormasterBuildQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->withBuildablePHIDs(array($this->getPHID()))
|
||||||
|
->execute();
|
||||||
|
foreach ($builds as $build) {
|
||||||
|
$engine->destroyObject($build);
|
||||||
|
}
|
||||||
|
|
||||||
|
$messages = id(new HarbormasterBuildMessageQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->withReceiverPHIDs(array($this->getPHID()))
|
||||||
|
->execute();
|
||||||
|
foreach ($messages as $message) {
|
||||||
|
$engine->destroyObject($message);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->delete();
|
||||||
|
$this->saveTransaction();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,8 @@ final class HarbormasterBuild extends HarbormasterDAO
|
||||||
implements
|
implements
|
||||||
PhabricatorApplicationTransactionInterface,
|
PhabricatorApplicationTransactionInterface,
|
||||||
PhabricatorPolicyInterface,
|
PhabricatorPolicyInterface,
|
||||||
PhabricatorConduitResultInterface {
|
PhabricatorConduitResultInterface,
|
||||||
|
PhabricatorDestructibleInterface {
|
||||||
|
|
||||||
protected $buildablePHID;
|
protected $buildablePHID;
|
||||||
protected $buildPlanPHID;
|
protected $buildPlanPHID;
|
||||||
|
@ -455,4 +456,33 @@ final class HarbormasterBuild extends HarbormasterDAO
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* -( PhabricatorDestructibleInterface )----------------------------------- */
|
||||||
|
|
||||||
|
public function destroyObjectPermanently(
|
||||||
|
PhabricatorDestructionEngine $engine) {
|
||||||
|
$viewer = $engine->getViewer();
|
||||||
|
|
||||||
|
$this->openTransaction();
|
||||||
|
$targets = id(new HarbormasterBuildTargetQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->withBuildPHIDs(array($this->getPHID()))
|
||||||
|
->execute();
|
||||||
|
foreach ($targets as $target) {
|
||||||
|
$engine->destroyObject($target);
|
||||||
|
}
|
||||||
|
|
||||||
|
$messages = id(new HarbormasterBuildMessageQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->withReceiverPHIDs(array($this->getPHID()))
|
||||||
|
->execute();
|
||||||
|
foreach ($messages as $message) {
|
||||||
|
$engine->destroyObject($message);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->delete();
|
||||||
|
$this->saveTransaction();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class HarbormasterBuildArtifact extends HarbormasterDAO
|
final class HarbormasterBuildArtifact
|
||||||
implements PhabricatorPolicyInterface {
|
extends HarbormasterDAO
|
||||||
|
implements
|
||||||
|
PhabricatorPolicyInterface,
|
||||||
|
PhabricatorDestructibleInterface {
|
||||||
|
|
||||||
protected $buildTargetPHID;
|
protected $buildTargetPHID;
|
||||||
protected $artifactType;
|
protected $artifactType;
|
||||||
|
@ -147,4 +150,19 @@ final class HarbormasterBuildArtifact extends HarbormasterDAO
|
||||||
return pht('Users must be able to see a buildable to see its artifacts.');
|
return pht('Users must be able to see a buildable to see its artifacts.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* -( PhabricatorDestructibleInterface )----------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
public function destroyObjectPermanently(
|
||||||
|
PhabricatorDestructionEngine $engine) {
|
||||||
|
|
||||||
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
|
$this->openTransaction();
|
||||||
|
$this->releaseArtifact($viewer);
|
||||||
|
$this->delete();
|
||||||
|
$this->saveTransaction();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class HarbormasterBuildTarget extends HarbormasterDAO
|
final class HarbormasterBuildTarget
|
||||||
implements PhabricatorPolicyInterface {
|
extends HarbormasterDAO
|
||||||
|
implements
|
||||||
|
PhabricatorPolicyInterface,
|
||||||
|
PhabricatorDestructibleInterface {
|
||||||
|
|
||||||
protected $name;
|
protected $name;
|
||||||
protected $buildPHID;
|
protected $buildPHID;
|
||||||
|
@ -354,4 +357,59 @@ final class HarbormasterBuildTarget extends HarbormasterDAO
|
||||||
return pht('Users must be able to see a build to view its build targets.');
|
return pht('Users must be able to see a build to view its build targets.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* -( PhabricatorDestructibleInterface )----------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
public function destroyObjectPermanently(
|
||||||
|
PhabricatorDestructionEngine $engine) {
|
||||||
|
$viewer = $engine->getViewer();
|
||||||
|
|
||||||
|
$this->openTransaction();
|
||||||
|
|
||||||
|
$lint_message = new HarbormasterBuildLintMessage();
|
||||||
|
$conn = $lint_message->establishConnection('w');
|
||||||
|
queryfx(
|
||||||
|
$conn,
|
||||||
|
'DELETE FROM %T WHERE buildTargetPHID = %s',
|
||||||
|
$lint_message->getTableName(),
|
||||||
|
$this->getPHID());
|
||||||
|
|
||||||
|
$unit_message = new HarbormasterBuildUnitMessage();
|
||||||
|
$conn = $unit_message->establishConnection('w');
|
||||||
|
queryfx(
|
||||||
|
$conn,
|
||||||
|
'DELETE FROM %T WHERE buildTargetPHID = %s',
|
||||||
|
$unit_message->getTableName(),
|
||||||
|
$this->getPHID());
|
||||||
|
|
||||||
|
$logs = id(new HarbormasterBuildLogQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->withBuildTargetPHIDs(array($this->getPHID()))
|
||||||
|
->execute();
|
||||||
|
foreach ($logs as $log) {
|
||||||
|
$engine->destroyObject($log);
|
||||||
|
}
|
||||||
|
|
||||||
|
$artifacts = id(new HarbormasterBuildArtifactQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->withBuildTargetPHIDs(array($this->getPHID()))
|
||||||
|
->execute();
|
||||||
|
foreach ($artifacts as $artifact) {
|
||||||
|
$engine->destroyObject($artifact);
|
||||||
|
}
|
||||||
|
|
||||||
|
$messages = id(new HarbormasterBuildMessageQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->withReceiverPHIDs(array($this->getPHID()))
|
||||||
|
->execute();
|
||||||
|
foreach ($messages as $message) {
|
||||||
|
$engine->destroyObject($message);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->delete();
|
||||||
|
$this->saveTransaction();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue