Page MenuHomestyx hydra

No OneTemporary

diff --git a/resources/sql/autopatches/20220525.slowvote.01.mailkey.php b/resources/sql/autopatches/20220525.slowvote.01.mailkey.php
new file mode 100644
index 0000000000..ed0355e105
--- /dev/null
+++ b/resources/sql/autopatches/20220525.slowvote.01.mailkey.php
@@ -0,0 +1,28 @@
+<?php
+
+$poll_table = new PhabricatorSlowvotePoll();
+$poll_conn = $poll_table->establishConnection('w');
+
+$properties_table = new PhabricatorMetaMTAMailProperties();
+$conn = $properties_table->establishConnection('w');
+
+$iterator = new LiskRawMigrationIterator(
+ $poll_conn,
+ $poll_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/20220525.slowvote.02.mailkey-drop.sql b/resources/sql/autopatches/20220525.slowvote.02.mailkey-drop.sql
new file mode 100644
index 0000000000..54e65fd14c
--- /dev/null
+++ b/resources/sql/autopatches/20220525.slowvote.02.mailkey-drop.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_slowvote.slowvote_poll
+ DROP mailKey;
diff --git a/src/applications/slowvote/storage/PhabricatorSlowvotePoll.php b/src/applications/slowvote/storage/PhabricatorSlowvotePoll.php
index 78e136762f..a78e030dc6 100644
--- a/src/applications/slowvote/storage/PhabricatorSlowvotePoll.php
+++ b/src/applications/slowvote/storage/PhabricatorSlowvotePoll.php
@@ -1,233 +1,224 @@
<?php
-final class PhabricatorSlowvotePoll extends PhabricatorSlowvoteDAO
+final class PhabricatorSlowvotePoll
+ extends PhabricatorSlowvoteDAO
implements
PhabricatorApplicationTransactionInterface,
PhabricatorPolicyInterface,
PhabricatorSubscribableInterface,
PhabricatorFlaggableInterface,
PhabricatorTokenReceiverInterface,
PhabricatorProjectInterface,
PhabricatorDestructibleInterface,
PhabricatorSpacesInterface,
PhabricatorConduitResultInterface {
const RESPONSES_VISIBLE = 0;
const RESPONSES_VOTERS = 1;
const RESPONSES_OWNER = 2;
const METHOD_PLURALITY = 0;
const METHOD_APPROVAL = 1;
protected $question;
protected $description;
protected $authorPHID;
protected $responseVisibility = 0;
protected $shuffle = 0;
protected $method;
- protected $mailKey;
protected $viewPolicy;
protected $isClosed = 0;
protected $spacePHID;
private $options = self::ATTACHABLE;
private $choices = self::ATTACHABLE;
private $viewerChoices = self::ATTACHABLE;
public static function initializeNewPoll(PhabricatorUser $actor) {
$app = id(new PhabricatorApplicationQuery())
->setViewer($actor)
->withClasses(array('PhabricatorSlowvoteApplication'))
->executeOne();
$view_policy = $app->getPolicy(
PhabricatorSlowvoteDefaultViewCapability::CAPABILITY);
return id(new PhabricatorSlowvotePoll())
->setAuthorPHID($actor->getPHID())
->setViewPolicy($view_policy)
->setSpacePHID($actor->getDefaultSpacePHID());
}
protected function getConfiguration() {
return array(
self::CONFIG_AUX_PHID => true,
self::CONFIG_COLUMN_SCHEMA => array(
'question' => 'text255',
'responseVisibility' => 'uint32',
'shuffle' => 'bool',
'method' => 'uint32',
'description' => 'text',
'isClosed' => 'bool',
- 'mailKey' => 'bytes20',
),
self::CONFIG_KEY_SCHEMA => array(
),
) + parent::getConfiguration();
}
- public function generatePHID() {
- return PhabricatorPHID::generateNewPHID(
- PhabricatorSlowvotePollPHIDType::TYPECONST);
+ public function getPHIDType() {
+ return PhabricatorSlowvotePollPHIDType::TYPECONST;
}
public function getOptions() {
return $this->assertAttached($this->options);
}
public function attachOptions(array $options) {
assert_instances_of($options, 'PhabricatorSlowvoteOption');
$this->options = $options;
return $this;
}
public function getChoices() {
return $this->assertAttached($this->choices);
}
public function attachChoices(array $choices) {
assert_instances_of($choices, 'PhabricatorSlowvoteChoice');
$this->choices = $choices;
return $this;
}
public function getViewerChoices(PhabricatorUser $viewer) {
return $this->assertAttachedKey($this->viewerChoices, $viewer->getPHID());
}
public function attachViewerChoices(PhabricatorUser $viewer, array $choices) {
if ($this->viewerChoices === self::ATTACHABLE) {
$this->viewerChoices = array();
}
assert_instances_of($choices, 'PhabricatorSlowvoteChoice');
$this->viewerChoices[$viewer->getPHID()] = $choices;
return $this;
}
public function getMonogram() {
return 'V'.$this->getID();
}
public function getURI() {
return '/'.$this->getMonogram();
}
- public function save() {
- if (!$this->getMailKey()) {
- $this->setMailKey(Filesystem::readRandomCharacters(20));
- }
- return parent::save();
- }
-
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
public function getApplicationTransactionEditor() {
return new PhabricatorSlowvoteEditor();
}
public function getApplicationTransactionTemplate() {
return new PhabricatorSlowvoteTransaction();
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */
public function getCapabilities() {
return array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
);
}
public function getPolicy($capability) {
switch ($capability) {
case PhabricatorPolicyCapability::CAN_VIEW:
return $this->viewPolicy;
case PhabricatorPolicyCapability::CAN_EDIT:
return PhabricatorPolicies::POLICY_NOONE;
}
}
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
return ($viewer->getPHID() == $this->getAuthorPHID());
}
public function describeAutomaticCapability($capability) {
return pht('The author of a poll can always view and edit it.');
}
/* -( PhabricatorSubscribableInterface )----------------------------------- */
public function isAutomaticallySubscribed($phid) {
return ($phid == $this->getAuthorPHID());
}
/* -( PhabricatorTokenReceiverInterface )---------------------------------- */
public function getUsersToNotifyOfTokenGiven() {
return array($this->getAuthorPHID());
}
/* -( PhabricatorDestructibleInterface )----------------------------------- */
public function destroyObjectPermanently(
PhabricatorDestructionEngine $engine) {
$this->openTransaction();
$choices = id(new PhabricatorSlowvoteChoice())->loadAllWhere(
'pollID = %d',
$this->getID());
foreach ($choices as $choice) {
$choice->delete();
}
$options = id(new PhabricatorSlowvoteOption())->loadAllWhere(
'pollID = %d',
$this->getID());
foreach ($options as $option) {
$option->delete();
}
$this->delete();
$this->saveTransaction();
}
/* -( PhabricatorSpacesInterface )----------------------------------------- */
public function getSpacePHID() {
return $this->spacePHID;
}
/* -( PhabricatorConduitResultInterface )---------------------------------- */
public function getFieldSpecificationsForConduit() {
return array(
id(new PhabricatorConduitSearchFieldSpecification())
->setKey('name')
->setType('string')
->setDescription(pht('The name of the poll.')),
id(new PhabricatorConduitSearchFieldSpecification())
->setKey('authorPHID')
->setType('string')
->setDescription(pht('The author of the poll.')),
);
}
public function getFieldValuesForConduit() {
return array(
'name' => $this->getQuestion(),
'authorPHID' => $this->getAuthorPHID(),
);
}
public function getConduitSearchAttachments() {
return array();
}
}

File Metadata

Mime Type
text/x-diff
Expires
Fri, Mar 14, 4:43 PM (1 d, 14 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
72043
Default Alt Text
(8 KB)

Event Timeline