Page MenuHomePhorge

D25900.1741691922.diff
No OneTemporary

D25900.1741691922.diff

diff --git a/resources/sql/autopatches/20250227.paste.01.mailkey.php b/resources/sql/autopatches/20250227.paste.01.mailkey.php
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20250227.paste.01.mailkey.php
@@ -0,0 +1,34 @@
+<?php
+
+$paste_table = new PhabricatorPaste();
+$paste_conn = $paste_table->establishConnection('w');
+
+$properties_table = new PhabricatorMetaMTAMailProperties();
+$conn = $properties_table->establishConnection('w');
+
+$iterator = new LiskRawMigrationIterator(
+ $paste_conn,
+ $paste_table->getTableName());
+
+foreach ($iterator as $row) {
+ // The mailKey field might be unpopulated.
+ // This should have happened in the 20130805.pastemailkeypop.php migration,
+ // but that will not work on newer installations, because the paste table
+ // was renamed in between.
+ $mailkey = $row['mailKey'] ?? Filesystem::readRandomCharacters(20);
+
+ queryfx(
+ $conn,
+ 'INSERT IGNORE INTO %T
+ (objectPHID, mailProperties, dateCreated, dateModified)
+ VALUES
+ (%s, %s, %d, %d)',
+ $properties_table->getTableName(),
+ $row['phid'],
+ phutil_json_encode(
+ array(
+ 'mailKey' => $mailkey,
+ )),
+ PhabricatorTime::getNow(),
+ PhabricatorTime::getNow());
+}
diff --git a/resources/sql/autopatches/20250227.paste.02.mailkey.sql b/resources/sql/autopatches/20250227.paste.02.mailkey.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20250227.paste.02.mailkey.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_paste.paste
+ DROP mailKey;
diff --git a/src/applications/paste/storage/PhabricatorPaste.php b/src/applications/paste/storage/PhabricatorPaste.php
--- a/src/applications/paste/storage/PhabricatorPaste.php
+++ b/src/applications/paste/storage/PhabricatorPaste.php
@@ -22,7 +22,6 @@
protected $parentPHID;
protected $viewPolicy;
protected $editPolicy;
- protected $mailKey;
protected $status;
protected $spacePHID;
@@ -74,7 +73,6 @@
'status' => 'text32',
'title' => 'text255',
'language' => 'text64?',
- 'mailKey' => 'bytes20',
'parentPHID' => 'phid?',
// T6203/NULLABILITY
@@ -107,13 +105,6 @@
return ($this->getStatus() == self::STATUS_ARCHIVED);
}
- public function save() {
- if (!$this->getMailKey()) {
- $this->setMailKey(Filesystem::readRandomCharacters(20));
- }
- return parent::save();
- }
-
public function getFullName() {
$title = $this->getTitle();
if (!$title) {

File Metadata

Mime Type
text/plain
Expires
Tue, Mar 11, 11:18 (1 d, 10 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1196759
Default Alt Text
D25900.1741691922.diff (2 KB)

Event Timeline