Page MenuHomestyx hydra

No OneTemporary

diff --git a/resources/sql/autopatches/20180212.harbor.01.receiver.sql b/resources/sql/autopatches/20180212.harbor.01.receiver.sql
new file mode 100644
index 0000000000..84e9611db2
--- /dev/null
+++ b/resources/sql/autopatches/20180212.harbor.01.receiver.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_harbormaster.harbormaster_buildmessage
+ CHANGE buildTargetPHID receiverPHID VARBINARY(64) NOT NULL;
diff --git a/src/applications/harbormaster/query/HarbormasterBuildMessageQuery.php b/src/applications/harbormaster/query/HarbormasterBuildMessageQuery.php
index 1b55f2e781..134c68ce04 100644
--- a/src/applications/harbormaster/query/HarbormasterBuildMessageQuery.php
+++ b/src/applications/harbormaster/query/HarbormasterBuildMessageQuery.php
@@ -1,92 +1,92 @@
<?php
final class HarbormasterBuildMessageQuery
extends PhabricatorCursorPagedPolicyAwareQuery {
private $ids;
private $receiverPHIDs;
private $consumed;
public function withIDs(array $ids) {
$this->ids = $ids;
return $this;
}
public function withReceiverPHIDs(array $phids) {
$this->receiverPHIDs = $phids;
return $this;
}
public function withConsumed($consumed) {
$this->consumed = $consumed;
return $this;
}
public function newResultObject() {
return new HarbormasterBuildMessage();
}
protected function loadPage() {
return $this->loadStandardPage($this->newResultObject());
}
protected function willFilterPage(array $page) {
$receiver_phids = array_filter(mpull($page, 'getReceiverPHID'));
if ($receiver_phids) {
$receivers = id(new PhabricatorObjectQuery())
->setViewer($this->getViewer())
->withPHIDs($receiver_phids)
->setParentQuery($this)
->execute();
$receivers = mpull($receivers, null, 'getPHID');
} else {
$receivers = array();
}
foreach ($page as $key => $message) {
$receiver_phid = $message->getReceiverPHID();
if (empty($receivers[$receiver_phid])) {
unset($page[$key]);
$this->didRejectResult($message);
continue;
}
$message->attachReceiver($receivers[$receiver_phid]);
}
return $page;
}
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
$where = parent::buildWhereClauseParts($conn);
if ($this->ids !== null) {
$where[] = qsprintf(
$conn,
'id IN (%Ld)',
$this->ids);
}
if ($this->receiverPHIDs !== null) {
$where[] = qsprintf(
$conn,
- 'buildTargetPHID IN (%Ls)',
+ 'receiverPHID IN (%Ls)',
$this->receiverPHIDs);
}
if ($this->consumed !== null) {
$where[] = qsprintf(
$conn,
'isConsumed = %d',
(int)$this->consumed);
}
return $where;
}
public function getQueryApplicationClass() {
return 'PhabricatorHarbormasterApplication';
}
}
diff --git a/src/applications/harbormaster/storage/HarbormasterBuildMessage.php b/src/applications/harbormaster/storage/HarbormasterBuildMessage.php
index 5c9c92b2fc..1066a93610 100644
--- a/src/applications/harbormaster/storage/HarbormasterBuildMessage.php
+++ b/src/applications/harbormaster/storage/HarbormasterBuildMessage.php
@@ -1,89 +1,77 @@
<?php
/**
* A message sent to an executing build target by an external system. We
* capture these messages and process them asynchronously to avoid race
* conditions where we receive a message before a build plan is ready to
* accept it.
*/
final class HarbormasterBuildMessage extends HarbormasterDAO
implements PhabricatorPolicyInterface {
protected $authorPHID;
- protected $buildTargetPHID;
+ protected $receiverPHID;
protected $type;
protected $isConsumed;
private $receiver = self::ATTACHABLE;
public static function initializeNewMessage(PhabricatorUser $actor) {
$actor_phid = $actor->getPHID();
if (!$actor_phid) {
$actor_phid = id(new PhabricatorHarbormasterApplication())->getPHID();
}
return id(new HarbormasterBuildMessage())
->setAuthorPHID($actor_phid)
->setIsConsumed(0);
}
protected function getConfiguration() {
return array(
self::CONFIG_COLUMN_SCHEMA => array(
'type' => 'text16',
'isConsumed' => 'bool',
),
self::CONFIG_KEY_SCHEMA => array(
- 'key_buildtarget' => array(
- 'columns' => array('buildTargetPHID'),
+ 'key_receiver' => array(
+ 'columns' => array('receiverPHID'),
),
),
) + parent::getConfiguration();
}
- public function getReceiverPHID() {
- return $this->getBuildTargetPHID();
- }
-
- public function setReceiverPHID($phid) {
- return $this->setBuildTargetPHID($phid);
- }
-
public function getReceiver() {
return $this->assertAttached($this->receiver);
}
- public function getBuildTarget() {
- return $this->getReceiver();
- }
-
public function attachReceiver($receiver) {
$this->receiver = $receiver;
return $this;
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */
public function getCapabilities() {
return array(
PhabricatorPolicyCapability::CAN_VIEW,
);
}
public function getPolicy($capability) {
return $this->getReceiver()->getPolicy($capability);
}
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
return $this->getReceiver()->hasAutomaticCapability(
$capability,
$viewer);
}
public function describeAutomaticCapability($capability) {
return pht('Build messages have the same policies as their receivers.');
}
}

File Metadata

Mime Type
text/x-diff
Expires
Fri, Mar 14, 1:25 PM (1 d, 3 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
71901
Default Alt Text
(5 KB)

Event Timeline