Page MenuHomePhorge

D25900.1741572500.diff
No OneTemporary

D25900.1741572500.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;

File Metadata

Mime Type
text/plain
Expires
Mon, Mar 10, 02:08 (2 d, 19 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1196761
Default Alt Text
D25900.1741572500.diff (1 KB)

Event Timeline