@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add mailKey to macros

Summary:
If you have private replies on and a Macro reply handler set, we try to access `getMailKey()` and fail. See P1039 for a trace.

(Thanks to @Korvin for picking this up.)

Test Plan: Set configuration, repro'd the exception, applied the patch, then disabled/enabled a macro.

Reviewers: btrahan

Reviewed By: btrahan

CC: Korvin, aran

Differential Revision: https://secure.phabricator.com/D7896

+48 -2
+2
resources/sql/autopatches/20140106.macromailkey.1.sql
··· 1 + ALTER TABLE {$NAMESPACE}_file.file_imagemacro 2 + ADD mailKey VARCHAR(20) NOT NULL COLLATE utf8_bin;
+23
resources/sql/autopatches/20140106.macromailkey.2.php
··· 1 + <?php 2 + 3 + echo "Adding mailkeys to macros.\n"; 4 + 5 + $table = new PhabricatorFileImageMacro(); 6 + $conn_w = $table->establishConnection('w'); 7 + $iterator = new LiskMigrationIterator($table); 8 + foreach ($iterator as $macro) { 9 + $id = $macro->getID(); 10 + 11 + echo "Populating macro {$id}...\n"; 12 + 13 + if (!$macro->getMailKey()) { 14 + queryfx( 15 + $conn_w, 16 + 'UPDATE %T SET mailKey = %s WHERE id = %d', 17 + $table->getTableName(), 18 + Filesystem::readRandomCharacters(20), 19 + $id); 20 + } 21 + } 22 + 23 + echo "Done.\n";
+23 -2
src/applications/macro/storage/PhabricatorFileImageMacro.php
··· 13 13 protected $isDisabled = 0; 14 14 protected $audioPHID; 15 15 protected $audioBehavior = self::AUDIO_BEHAVIOR_NONE; 16 + protected $mailKey; 16 17 17 18 private $file = self::ATTACHABLE; 18 19 private $audio = self::ATTACHABLE; ··· 50 51 PhabricatorMacroPHIDTypeMacro::TYPECONST); 51 52 } 52 53 53 - public function isAutomaticallySubscribed($phid) { 54 - return false; 54 + 55 + public function save() { 56 + if (!$this->getMailKey()) { 57 + $this->setMailKey(Filesystem::readRandomCharacters(20)); 58 + } 59 + return parent::save(); 55 60 } 61 + 62 + 63 + /* -( PhabricatorApplicationTransactionInterface )------------------------- */ 64 + 56 65 57 66 public function getApplicationTransactionEditor() { 58 67 return new PhabricatorMacroEditor(); ··· 61 70 public function getApplicationTransactionObject() { 62 71 return new PhabricatorMacroTransaction(); 63 72 } 73 + 74 + 75 + /* -( PhabricatorSubscribableInterface )----------------------------------- */ 76 + 77 + 78 + public function isAutomaticallySubscribed($phid) { 79 + return false; 80 + } 81 + 82 + 83 + /* -( PhabricatorPolicyInterface )----------------------------------------- */ 84 + 64 85 65 86 public function getCapabilities() { 66 87 return array(