@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+162 -9
+5
src/__phutil_library_map__.php
··· 6525 6525 'PhabricatorApplicationTransactionInterface', 6526 6526 'PhabricatorPolicyInterface', 6527 6527 'PhabricatorConduitResultInterface', 6528 + 'PhabricatorDestructibleInterface', 6528 6529 ), 6529 6530 'HarbormasterBuildAbortedException' => 'Exception', 6530 6531 'HarbormasterBuildActionController' => 'HarbormasterController', ··· 6532 6533 'HarbormasterBuildArtifact' => array( 6533 6534 'HarbormasterDAO', 6534 6535 'PhabricatorPolicyInterface', 6536 + 'PhabricatorDestructibleInterface', 6535 6537 ), 6536 6538 'HarbormasterBuildArtifactPHIDType' => 'PhabricatorPHIDType', 6537 6539 'HarbormasterBuildArtifactQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', ··· 6564 6566 'HarbormasterBuildMessage' => array( 6565 6567 'HarbormasterDAO', 6566 6568 'PhabricatorPolicyInterface', 6569 + 'PhabricatorDestructibleInterface', 6567 6570 ), 6568 6571 'HarbormasterBuildMessageQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 6569 6572 'HarbormasterBuildPHIDType' => 'PhabricatorPHIDType', ··· 6614 6617 'HarbormasterBuildTarget' => array( 6615 6618 'HarbormasterDAO', 6616 6619 'PhabricatorPolicyInterface', 6620 + 'PhabricatorDestructibleInterface', 6617 6621 ), 6618 6622 'HarbormasterBuildTargetPHIDType' => 'PhabricatorPHIDType', 6619 6623 'HarbormasterBuildTargetQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', ··· 6628 6632 'PhabricatorApplicationTransactionInterface', 6629 6633 'PhabricatorPolicyInterface', 6630 6634 'HarbormasterBuildableInterface', 6635 + 'PhabricatorDestructibleInterface', 6631 6636 ), 6632 6637 'HarbormasterBuildableActionController' => 'HarbormasterController', 6633 6638 'HarbormasterBuildableListController' => 'HarbormasterController',
+14 -2
src/applications/harbormaster/storage/HarbormasterBuildMessage.php
··· 6 6 * conditions where we receive a message before a build plan is ready to 7 7 * accept it. 8 8 */ 9 - final class HarbormasterBuildMessage extends HarbormasterDAO 10 - implements PhabricatorPolicyInterface { 9 + final class HarbormasterBuildMessage 10 + extends HarbormasterDAO 11 + implements 12 + PhabricatorPolicyInterface, 13 + PhabricatorDestructibleInterface { 11 14 12 15 protected $authorPHID; 13 16 protected $receiverPHID; ··· 72 75 73 76 public function describeAutomaticCapability($capability) { 74 77 return pht('Build messages have the same policies as their receivers.'); 78 + } 79 + 80 + 81 + /* -( PhabricatorDestructibleInterface )----------------------------------- */ 82 + 83 + 84 + public function destroyObjectPermanently( 85 + PhabricatorDestructionEngine $engine) { 86 + $this->delete(); 75 87 } 76 88 77 89 }
+32 -2
src/applications/harbormaster/storage/HarbormasterBuildable.php
··· 1 1 <?php 2 2 3 - final class HarbormasterBuildable extends HarbormasterDAO 3 + final class HarbormasterBuildable 4 + extends HarbormasterDAO 4 5 implements 5 6 PhabricatorApplicationTransactionInterface, 6 7 PhabricatorPolicyInterface, 7 - HarbormasterBuildableInterface { 8 + HarbormasterBuildableInterface, 9 + PhabricatorDestructibleInterface { 8 10 9 11 protected $buildablePHID; 10 12 protected $containerPHID; ··· 339 341 return array(); 340 342 } 341 343 344 + 345 + /* -( PhabricatorDestructibleInterface )----------------------------------- */ 346 + 347 + 348 + public function destroyObjectPermanently( 349 + PhabricatorDestructionEngine $engine) { 350 + $viewer = $engine->getViewer(); 351 + 352 + $this->openTransaction(); 353 + $builds = id(new HarbormasterBuildQuery()) 354 + ->setViewer($viewer) 355 + ->withBuildablePHIDs(array($this->getPHID())) 356 + ->execute(); 357 + foreach ($builds as $build) { 358 + $engine->destroyObject($build); 359 + } 360 + 361 + $messages = id(new HarbormasterBuildMessageQuery()) 362 + ->setViewer($viewer) 363 + ->withReceiverPHIDs(array($this->getPHID())) 364 + ->execute(); 365 + foreach ($messages as $message) { 366 + $engine->destroyObject($message); 367 + } 368 + 369 + $this->delete(); 370 + $this->saveTransaction(); 371 + } 342 372 343 373 }
+31 -1
src/applications/harbormaster/storage/build/HarbormasterBuild.php
··· 4 4 implements 5 5 PhabricatorApplicationTransactionInterface, 6 6 PhabricatorPolicyInterface, 7 - PhabricatorConduitResultInterface { 7 + PhabricatorConduitResultInterface, 8 + PhabricatorDestructibleInterface { 8 9 9 10 protected $buildablePHID; 10 11 protected $buildPlanPHID; ··· 454 455 ->setAttachmentKey('querybuilds'), 455 456 ); 456 457 } 458 + 459 + 460 + /* -( PhabricatorDestructibleInterface )----------------------------------- */ 461 + 462 + public function destroyObjectPermanently( 463 + PhabricatorDestructionEngine $engine) { 464 + $viewer = $engine->getViewer(); 465 + 466 + $this->openTransaction(); 467 + $targets = id(new HarbormasterBuildTargetQuery()) 468 + ->setViewer($viewer) 469 + ->withBuildPHIDs(array($this->getPHID())) 470 + ->execute(); 471 + foreach ($targets as $target) { 472 + $engine->destroyObject($target); 473 + } 474 + 475 + $messages = id(new HarbormasterBuildMessageQuery()) 476 + ->setViewer($viewer) 477 + ->withReceiverPHIDs(array($this->getPHID())) 478 + ->execute(); 479 + foreach ($messages as $message) { 480 + $engine->destroyObject($message); 481 + } 482 + 483 + $this->delete(); 484 + $this->saveTransaction(); 485 + } 486 + 457 487 458 488 }
+20 -2
src/applications/harbormaster/storage/build/HarbormasterBuildArtifact.php
··· 1 1 <?php 2 2 3 - final class HarbormasterBuildArtifact extends HarbormasterDAO 4 - implements PhabricatorPolicyInterface { 3 + final class HarbormasterBuildArtifact 4 + extends HarbormasterDAO 5 + implements 6 + PhabricatorPolicyInterface, 7 + PhabricatorDestructibleInterface { 5 8 6 9 protected $buildTargetPHID; 7 10 protected $artifactType; ··· 145 148 146 149 public function describeAutomaticCapability($capability) { 147 150 return pht('Users must be able to see a buildable to see its artifacts.'); 151 + } 152 + 153 + 154 + /* -( PhabricatorDestructibleInterface )----------------------------------- */ 155 + 156 + 157 + public function destroyObjectPermanently( 158 + PhabricatorDestructionEngine $engine) { 159 + 160 + $viewer = $this->getViewer(); 161 + 162 + $this->openTransaction(); 163 + $this->releaseArtifact($viewer); 164 + $this->delete(); 165 + $this->saveTransaction(); 148 166 } 149 167 150 168 }
+60 -2
src/applications/harbormaster/storage/build/HarbormasterBuildTarget.php
··· 1 1 <?php 2 2 3 - final class HarbormasterBuildTarget extends HarbormasterDAO 4 - implements PhabricatorPolicyInterface { 3 + final class HarbormasterBuildTarget 4 + extends HarbormasterDAO 5 + implements 6 + PhabricatorPolicyInterface, 7 + PhabricatorDestructibleInterface { 5 8 6 9 protected $name; 7 10 protected $buildPHID; ··· 353 356 public function describeAutomaticCapability($capability) { 354 357 return pht('Users must be able to see a build to view its build targets.'); 355 358 } 359 + 360 + 361 + /* -( PhabricatorDestructibleInterface )----------------------------------- */ 362 + 363 + 364 + public function destroyObjectPermanently( 365 + PhabricatorDestructionEngine $engine) { 366 + $viewer = $engine->getViewer(); 367 + 368 + $this->openTransaction(); 369 + 370 + $lint_message = new HarbormasterBuildLintMessage(); 371 + $conn = $lint_message->establishConnection('w'); 372 + queryfx( 373 + $conn, 374 + 'DELETE FROM %T WHERE buildTargetPHID = %s', 375 + $lint_message->getTableName(), 376 + $this->getPHID()); 377 + 378 + $unit_message = new HarbormasterBuildUnitMessage(); 379 + $conn = $unit_message->establishConnection('w'); 380 + queryfx( 381 + $conn, 382 + 'DELETE FROM %T WHERE buildTargetPHID = %s', 383 + $unit_message->getTableName(), 384 + $this->getPHID()); 385 + 386 + $logs = id(new HarbormasterBuildLogQuery()) 387 + ->setViewer($viewer) 388 + ->withBuildTargetPHIDs(array($this->getPHID())) 389 + ->execute(); 390 + foreach ($logs as $log) { 391 + $engine->destroyObject($log); 392 + } 393 + 394 + $artifacts = id(new HarbormasterBuildArtifactQuery()) 395 + ->setViewer($viewer) 396 + ->withBuildTargetPHIDs(array($this->getPHID())) 397 + ->execute(); 398 + foreach ($artifacts as $artifact) { 399 + $engine->destroyObject($artifact); 400 + } 401 + 402 + $messages = id(new HarbormasterBuildMessageQuery()) 403 + ->setViewer($viewer) 404 + ->withReceiverPHIDs(array($this->getPHID())) 405 + ->execute(); 406 + foreach ($messages as $message) { 407 + $engine->destroyObject($message); 408 + } 409 + 410 + $this->delete(); 411 + $this->saveTransaction(); 412 + } 413 + 356 414 357 415 }