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

Rename "HarbormasterBuild" methods to prepare for use of the "BuildMessages" table

Summary:
Ref T13072. Rename various "command" properties to "message" properties, to prepare for merging "HarbormasterCommand" into "HarbormasterMessage".

This change only renames variables and methods and should not affect program behavior.

Test Plan: Grepped for affected symbols, found no unmodified hits.

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13072

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

+36 -30
+1 -1
src/applications/harbormaster/engine/HarbormasterBuildEngine.php
··· 127 127 $build->save(); 128 128 } 129 129 130 - $build->deleteUnprocessedCommands(); 130 + $build->markUnprocessedMessagesAsProcessed(); 131 131 132 132 if ($build->getBuildStatus() == HarbormasterBuildStatus::STATUS_BUILDING) { 133 133 $this->updateBuildSteps($build);
+4 -4
src/applications/harbormaster/query/HarbormasterBuildQuery.php
··· 104 104 } 105 105 106 106 $build_phids = mpull($page, 'getPHID'); 107 - $commands = id(new HarbormasterBuildCommand())->loadAllWhere( 107 + $messages = id(new HarbormasterBuildCommand())->loadAllWhere( 108 108 'targetPHID IN (%Ls) ORDER BY id ASC', 109 109 $build_phids); 110 - $commands = mgroup($commands, 'getTargetPHID'); 110 + $messages = mgroup($messages, 'getTargetPHID'); 111 111 foreach ($page as $build) { 112 - $unprocessed_commands = idx($commands, $build->getPHID(), array()); 113 - $build->attachUnprocessedCommands($unprocessed_commands); 112 + $unprocessed_messages = idx($messages, $build->getPHID(), array()); 113 + $build->attachUnprocessedMessages($unprocessed_messages); 114 114 } 115 115 116 116 if ($this->needBuildTargets) {
+31 -25
src/applications/harbormaster/storage/build/HarbormasterBuild.php
··· 18 18 private $buildable = self::ATTACHABLE; 19 19 private $buildPlan = self::ATTACHABLE; 20 20 private $buildTargets = self::ATTACHABLE; 21 - private $unprocessedCommands = self::ATTACHABLE; 21 + private $unprocessedMessages = self::ATTACHABLE; 22 22 23 23 public static function initializeNewBuild(PhabricatorUser $actor) { 24 24 return id(new HarbormasterBuild()) ··· 28 28 29 29 public function delete() { 30 30 $this->openTransaction(); 31 - $this->deleteUnprocessedCommands(); 31 + $this->deleteUnprocessedMessages(); 32 32 $result = parent::delete(); 33 33 $this->saveTransaction(); 34 34 ··· 222 222 } 223 223 224 224 225 - /* -( Build Commands )----------------------------------------------------- */ 225 + /* -( Build Messages )----------------------------------------------------- */ 226 226 227 227 228 - private function getUnprocessedCommands() { 229 - return $this->assertAttached($this->unprocessedCommands); 228 + private function getUnprocessedMessages() { 229 + return $this->assertAttached($this->unprocessedMessages); 230 230 } 231 231 232 - public function attachUnprocessedCommands(array $commands) { 233 - $this->unprocessedCommands = $commands; 232 + public function attachUnprocessedMessages(array $messages) { 233 + $this->unprocessedMessages = $messages; 234 234 return $this; 235 235 } 236 236 ··· 330 330 331 331 public function isPausing() { 332 332 $is_pausing = false; 333 - foreach ($this->getUnprocessedCommands() as $command_object) { 334 - $command = $command_object->getCommand(); 335 - switch ($command) { 333 + foreach ($this->getUnprocessedMessages() as $message_object) { 334 + $message_type = $message_object->getCommand(); 335 + switch ($message_type) { 336 336 case HarbormasterBuildCommand::COMMAND_PAUSE: 337 337 $is_pausing = true; 338 338 break; ··· 351 351 352 352 public function isResuming() { 353 353 $is_resuming = false; 354 - foreach ($this->getUnprocessedCommands() as $command_object) { 355 - $command = $command_object->getCommand(); 356 - switch ($command) { 354 + foreach ($this->getUnprocessedMessages() as $message_object) { 355 + $message_type = $message_object->getCommand(); 356 + switch ($message_type) { 357 357 case HarbormasterBuildCommand::COMMAND_RESTART: 358 358 case HarbormasterBuildCommand::COMMAND_RESUME: 359 359 $is_resuming = true; ··· 372 372 373 373 public function isRestarting() { 374 374 $is_restarting = false; 375 - foreach ($this->getUnprocessedCommands() as $command_object) { 376 - $command = $command_object->getCommand(); 377 - switch ($command) { 375 + foreach ($this->getUnprocessedMessages() as $message_object) { 376 + $message_type = $message_object->getCommand(); 377 + switch ($message_type) { 378 378 case HarbormasterBuildCommand::COMMAND_RESTART: 379 379 $is_restarting = true; 380 380 break; ··· 386 386 387 387 public function isAborting() { 388 388 $is_aborting = false; 389 - foreach ($this->getUnprocessedCommands() as $command_object) { 390 - $command = $command_object->getCommand(); 391 - switch ($command) { 389 + foreach ($this->getUnprocessedMessages() as $message_object) { 390 + $message_type = $message_object->getCommand(); 391 + switch ($message_type) { 392 392 case HarbormasterBuildCommand::COMMAND_ABORT: 393 393 $is_aborting = true; 394 394 break; ··· 398 398 return $is_aborting; 399 399 } 400 400 401 - public function deleteUnprocessedCommands() { 402 - foreach ($this->getUnprocessedCommands() as $key => $command_object) { 403 - $command_object->delete(); 404 - unset($this->unprocessedCommands[$key]); 401 + public function markUnprocessedMessagesAsProcessed() { 402 + // TODO: See T13072. This is a placeholder until BuildCommand and 403 + // BuildMessage merge. 404 + return $this->deleteUnprocessedMessages(); 405 + } 406 + 407 + public function deleteUnprocessedMessages() { 408 + foreach ($this->getUnprocessedMessages() as $key => $message_object) { 409 + $message_object->delete(); 410 + unset($this->unprocessedMessages[$key]); 405 411 } 406 412 407 413 return $this; ··· 452 458 } 453 459 } 454 460 455 - public function sendMessage(PhabricatorUser $viewer, $command) { 461 + public function sendMessage(PhabricatorUser $viewer, $message_type) { 456 462 // TODO: This should not be an editor transaction, but there are plans to 457 463 // merge BuildCommand into BuildMessage which should moot this. As this 458 464 // exists today, it can race against BuildEngine. ··· 476 482 477 483 $xaction = id(new HarbormasterBuildTransaction()) 478 484 ->setTransactionType(HarbormasterBuildTransaction::TYPE_COMMAND) 479 - ->setNewValue($command); 485 + ->setNewValue($message_type); 480 486 481 487 $editor->applyTransactions($this, array($xaction)); 482 488 }