@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.

Implement DestructibleInterface on BuildLog

Summary: Depends on D19133. Ref T13088. Allows build logs to be formally destroyed, cleaning up their chunks and file data.

Test Plan:
- Used `bin/remove destroy` to destroy a log, verified chunks and files were removed.
- Used `bin/harbormaster rebuild-log` to force a log to rebuild, verified files were destroyed and regenerated.

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13088

Differential Revision: https://secure.phabricator.com/D19134

+54 -16
+1
src/__phutil_library_map__.php
··· 6511 6511 'HarbormasterBuildLog' => array( 6512 6512 'HarbormasterDAO', 6513 6513 'PhabricatorPolicyInterface', 6514 + 'PhabricatorDestructibleInterface', 6514 6515 ), 6515 6516 'HarbormasterBuildLogChunk' => 'HarbormasterDAO', 6516 6517 'HarbormasterBuildLogChunkIterator' => 'PhutilBufferedIterator',
+52 -2
src/applications/harbormaster/storage/build/HarbormasterBuildLog.php
··· 2 2 3 3 final class HarbormasterBuildLog 4 4 extends HarbormasterDAO 5 - implements PhabricatorPolicyInterface { 5 + implements 6 + PhabricatorPolicyInterface, 7 + PhabricatorDestructibleInterface { 6 8 7 9 protected $buildTargetPHID; 8 10 protected $logSource; ··· 317 319 318 320 public function describeAutomaticCapability($capability) { 319 321 return pht( 320 - "Users must be able to see a build target to view it's build log."); 322 + 'Users must be able to see a build target to view its build log.'); 323 + } 324 + 325 + 326 + /* -( PhabricatorDestructibleInterface )----------------------------------- */ 327 + 328 + 329 + public function destroyObjectPermanently( 330 + PhabricatorDestructionEngine $engine) { 331 + $this->destroyFile($engine); 332 + $this->destroyChunks(); 333 + $this->delete(); 334 + } 335 + 336 + public function destroyFile(PhabricatorDestructionEngine $engine = null) { 337 + if (!$engine) { 338 + $engine = new PhabricatorDestructionEngine(); 339 + } 340 + 341 + $file_phid = $this->getFilePHID(); 342 + if ($file_phid) { 343 + $viewer = $engine->getViewer(); 344 + $file = id(new PhabricatorFileQuery()) 345 + ->setViewer($viewer) 346 + ->withPHIDs(array($file_phid)) 347 + ->executeOne(); 348 + if ($file) { 349 + $engine->destroyObject($file); 350 + } 351 + } 352 + 353 + $this->setFilePHID(null); 354 + 355 + return $this; 356 + } 357 + 358 + public function destroyChunks() { 359 + $chunk = new HarbormasterBuildLogChunk(); 360 + $conn = $chunk->establishConnection('w'); 361 + 362 + // Just delete the chunks directly so we don't have to pull the data over 363 + // the wire for large logs. 364 + queryfx( 365 + $conn, 366 + 'DELETE FROM %T WHERE logID = %d', 367 + $chunk->getTableName(), 368 + $this->getID()); 369 + 370 + return $this; 321 371 } 322 372 323 373
+1 -14
src/applications/harbormaster/worker/HarbormasterLogWorker.php
··· 62 62 } 63 63 64 64 if ($is_force) { 65 - $file_phid = $log->getFilePHID(); 66 - if ($file_phid) { 67 - $file = id(new PhabricatorFileQuery()) 68 - ->setViewer($viewer) 69 - ->withPHIDs(array($file_phid)) 70 - ->executeOne(); 71 - if ($file) { 72 - id(new PhabricatorDestructionEngine()) 73 - ->destroyObject($file); 74 - } 75 - $log 76 - ->setFilePHID(null) 77 - ->save(); 78 - } 65 + $log->destroyFile(); 79 66 } 80 67 81 68 if (!$log->getFilePHID()) {