Page MenuHomePhabricator

D13785.id33299.diff
No OneTemporary

D13785.id33299.diff

diff --git a/resources/sql/autopatches/20150804.ponder.answer.mailkey.1.sql b/resources/sql/autopatches/20150804.ponder.answer.mailkey.1.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20150804.ponder.answer.mailkey.1.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_ponder.ponder_answer
+ ADD mailKey binary(20) NOT NULL;
diff --git a/resources/sql/autopatches/20150804.ponder.answer.mailkey.2.php b/resources/sql/autopatches/20150804.ponder.answer.mailkey.2.php
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20150804.ponder.answer.mailkey.2.php
@@ -0,0 +1,18 @@
+<?php
+
+$table = new PonderAnswer();
+$conn_w = $table->establishConnection('w');
+$iterator = new LiskMigrationIterator($table);
+foreach ($iterator as $answer) {
+ $id = $answer->getID();
+
+ echo pht('Adding mail key for Answer %d...', $id);
+ echo "\n";
+
+ queryfx(
+ $conn_w,
+ 'UPDATE %T SET mailKey = %s WHERE id = %d',
+ $table->getTableName(),
+ Filesystem::readRandomCharacters(20),
+ $id);
+}
diff --git a/src/applications/ponder/storage/PonderAnswer.php b/src/applications/ponder/storage/PonderAnswer.php
--- a/src/applications/ponder/storage/PonderAnswer.php
+++ b/src/applications/ponder/storage/PonderAnswer.php
@@ -18,6 +18,7 @@
protected $content;
protected $contentSource;
+ protected $mailKey;
protected $voteCount;
private $vote;
@@ -71,6 +72,7 @@
self::CONFIG_COLUMN_SCHEMA => array(
'voteCount' => 'sint32',
'content' => 'text',
+ 'mailKey' => 'bytes20',
// T6203/NULLABILITY
// This should always exist.
@@ -113,6 +115,13 @@
return self::MARKUP_FIELD_CONTENT;
}
+ public function save() {
+ if (!$this->getMailKey()) {
+ $this->setMailKey(Filesystem::readRandomCharacters(20));
+ }
+ return parent::save();
+ }
+
/* -( PhabricatorApplicationTransactionInterface )------------------------- */

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 8, 3:25 AM (1 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6737447
Default Alt Text
D13785.id33299.diff (1 KB)

Event Timeline