Page MenuHomestyx hydra

No OneTemporary

diff --git a/resources/sql/autopatches/20210316.almanac.05.service-mailkey.php b/resources/sql/autopatches/20210316.almanac.05.service-mailkey.php
new file mode 100644
index 0000000000..33318eb663
--- /dev/null
+++ b/resources/sql/autopatches/20210316.almanac.05.service-mailkey.php
@@ -0,0 +1,28 @@
+<?php
+
+$service_table = new AlmanacService();
+$service_conn = $service_table->establishConnection('w');
+
+$properties_table = new PhabricatorMetaMTAMailProperties();
+$conn = $properties_table->establishConnection('w');
+
+$iterator = new LiskRawMigrationIterator(
+ $service_conn,
+ $service_table->getTableName());
+
+foreach ($iterator as $row) {
+ queryfx(
+ $conn,
+ 'INSERT IGNORE INTO %R
+ (objectPHID, mailProperties, dateCreated, dateModified)
+ VALUES
+ (%s, %s, %d, %d)',
+ $properties_table,
+ $row['phid'],
+ phutil_json_encode(
+ array(
+ 'mailKey' => $row['mailKey'],
+ )),
+ PhabricatorTime::getNow(),
+ PhabricatorTime::getNow());
+}
diff --git a/resources/sql/autopatches/20210316.almanac.06.service-dropmailkey.sql b/resources/sql/autopatches/20210316.almanac.06.service-dropmailkey.sql
new file mode 100644
index 0000000000..b9966eddf9
--- /dev/null
+++ b/resources/sql/autopatches/20210316.almanac.06.service-dropmailkey.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_almanac.almanac_service
+ DROP mailKey;
diff --git a/src/applications/almanac/storage/AlmanacService.php b/src/applications/almanac/storage/AlmanacService.php
index 1683ba1340..58a3f681df 100644
--- a/src/applications/almanac/storage/AlmanacService.php
+++ b/src/applications/almanac/storage/AlmanacService.php
@@ -1,312 +1,306 @@
<?php
final class AlmanacService
extends AlmanacDAO
implements
PhabricatorPolicyInterface,
PhabricatorApplicationTransactionInterface,
PhabricatorProjectInterface,
AlmanacPropertyInterface,
PhabricatorDestructibleInterface,
PhabricatorNgramsInterface,
PhabricatorConduitResultInterface,
PhabricatorExtendedPolicyInterface {
protected $name;
protected $nameIndex;
- protected $mailKey;
protected $viewPolicy;
protected $editPolicy;
protected $serviceType;
private $almanacProperties = self::ATTACHABLE;
private $bindings = self::ATTACHABLE;
private $activeBindings = self::ATTACHABLE;
private $serviceImplementation = self::ATTACHABLE;
public static function initializeNewService($type) {
$type_map = AlmanacServiceType::getAllServiceTypes();
$implementation = idx($type_map, $type);
if (!$implementation) {
throw new Exception(
pht(
'No Almanac service type "%s" exists!',
$type));
}
return id(new AlmanacService())
->setViewPolicy(PhabricatorPolicies::POLICY_USER)
->setEditPolicy(PhabricatorPolicies::POLICY_ADMIN)
->attachAlmanacProperties(array())
->setServiceType($type)
->attachServiceImplementation($implementation);
}
protected function getConfiguration() {
return array(
self::CONFIG_AUX_PHID => true,
self::CONFIG_COLUMN_SCHEMA => array(
'name' => 'text128',
'nameIndex' => 'bytes12',
- 'mailKey' => 'bytes20',
'serviceType' => 'text64',
),
self::CONFIG_KEY_SCHEMA => array(
'key_name' => array(
'columns' => array('nameIndex'),
'unique' => true,
),
'key_nametext' => array(
'columns' => array('name'),
),
'key_servicetype' => array(
'columns' => array('serviceType'),
),
),
) + parent::getConfiguration();
}
- public function generatePHID() {
- return PhabricatorPHID::generateNewPHID(AlmanacServicePHIDType::TYPECONST);
+ public function getPHIDType() {
+ return AlmanacServicePHIDType::TYPECONST;
}
public function save() {
AlmanacNames::validateName($this->getName());
$this->nameIndex = PhabricatorHash::digestForIndex($this->getName());
- if (!$this->mailKey) {
- $this->mailKey = Filesystem::readRandomCharacters(20);
- }
-
return parent::save();
}
public function getURI() {
return '/almanac/service/view/'.$this->getName().'/';
}
public function getBindings() {
return $this->assertAttached($this->bindings);
}
public function getActiveBindings() {
return $this->assertAttached($this->activeBindings);
}
public function attachBindings(array $bindings) {
$active_bindings = array();
foreach ($bindings as $key => $binding) {
// Filter out disabled bindings.
if ($binding->getIsDisabled()) {
continue;
}
// Filter out bindings to disabled devices.
if ($binding->getDevice()->isDisabled()) {
continue;
}
$active_bindings[$key] = $binding;
}
$this->attachActiveBindings($active_bindings);
$this->bindings = $bindings;
return $this;
}
public function attachActiveBindings(array $bindings) {
$this->activeBindings = $bindings;
return $this;
}
public function getServiceImplementation() {
return $this->assertAttached($this->serviceImplementation);
}
public function attachServiceImplementation(AlmanacServiceType $type) {
$this->serviceImplementation = $type;
return $this;
}
public function isClusterService() {
return $this->getServiceImplementation()->isClusterServiceType();
}
/* -( AlmanacPropertyInterface )------------------------------------------- */
public function attachAlmanacProperties(array $properties) {
assert_instances_of($properties, 'AlmanacProperty');
$this->almanacProperties = mpull($properties, null, 'getFieldName');
return $this;
}
public function getAlmanacProperties() {
return $this->assertAttached($this->almanacProperties);
}
public function hasAlmanacProperty($key) {
$this->assertAttached($this->almanacProperties);
return isset($this->almanacProperties[$key]);
}
public function getAlmanacProperty($key) {
return $this->assertAttachedKey($this->almanacProperties, $key);
}
public function getAlmanacPropertyValue($key, $default = null) {
if ($this->hasAlmanacProperty($key)) {
return $this->getAlmanacProperty($key)->getFieldValue();
} else {
return $default;
}
}
public function getAlmanacPropertyFieldSpecifications() {
return $this->getServiceImplementation()->getFieldSpecifications();
}
public function getBindingFieldSpecifications(AlmanacBinding $binding) {
$impl = $this->getServiceImplementation();
return $impl->getBindingFieldSpecifications($binding);
}
public function newAlmanacPropertyEditEngine() {
return new AlmanacServicePropertyEditEngine();
}
public function getAlmanacPropertySetTransactionType() {
return AlmanacServiceSetPropertyTransaction::TRANSACTIONTYPE;
}
public function getAlmanacPropertyDeleteTransactionType() {
return AlmanacServiceDeletePropertyTransaction::TRANSACTIONTYPE;
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */
public function getCapabilities() {
return array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
);
}
public function getPolicy($capability) {
switch ($capability) {
case PhabricatorPolicyCapability::CAN_VIEW:
return $this->getViewPolicy();
case PhabricatorPolicyCapability::CAN_EDIT:
return $this->getEditPolicy();
}
}
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
return false;
}
/* -( PhabricatorExtendedPolicyInterface )--------------------------------- */
public function getExtendedPolicy($capability, PhabricatorUser $viewer) {
switch ($capability) {
case PhabricatorPolicyCapability::CAN_EDIT:
if ($this->isClusterService()) {
return array(
array(
new PhabricatorAlmanacApplication(),
AlmanacManageClusterServicesCapability::CAPABILITY,
),
);
}
break;
}
return array();
}
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
public function getApplicationTransactionEditor() {
return new AlmanacServiceEditor();
}
public function getApplicationTransactionTemplate() {
return new AlmanacServiceTransaction();
}
/* -( PhabricatorDestructibleInterface )----------------------------------- */
public function destroyObjectPermanently(
PhabricatorDestructionEngine $engine) {
$bindings = id(new AlmanacBindingQuery())
->setViewer($engine->getViewer())
->withServicePHIDs(array($this->getPHID()))
->execute();
foreach ($bindings as $binding) {
$engine->destroyObject($binding);
}
$this->delete();
}
/* -( PhabricatorNgramsInterface )----------------------------------------- */
public function newNgrams() {
return array(
id(new AlmanacServiceNameNgrams())
->setValue($this->getName()),
);
}
/* -( PhabricatorConduitResultInterface )---------------------------------- */
public function getFieldSpecificationsForConduit() {
return array(
id(new PhabricatorConduitSearchFieldSpecification())
->setKey('name')
->setType('string')
->setDescription(pht('The name of the service.')),
id(new PhabricatorConduitSearchFieldSpecification())
->setKey('serviceType')
->setType('string')
->setDescription(pht('The service type constant.')),
);
}
public function getFieldValuesForConduit() {
return array(
'name' => $this->getName(),
'serviceType' => $this->getServiceType(),
);
}
public function getConduitSearchAttachments() {
return array(
id(new AlmanacPropertiesSearchEngineAttachment())
->setAttachmentKey('properties'),
id(new AlmanacBindingsSearchEngineAttachment())
->setAttachmentKey('bindings'),
id(new AlmanacBindingsSearchEngineAttachment())
->setIsActive(true)
->setAttachmentKey('activeBindings'),
);
}
}

File Metadata

Mime Type
text/x-diff
Expires
Wed, Nov 26, 7:40 PM (15 h, 41 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
420205
Default Alt Text
(10 KB)

Event Timeline