mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 08:42:41 +01:00
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
This commit is contained in:
parent
d32c09de41
commit
6abe65bfdc
3 changed files with 48 additions and 2 deletions
2
resources/sql/autopatches/20140106.macromailkey.1.sql
Normal file
2
resources/sql/autopatches/20140106.macromailkey.1.sql
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE {$NAMESPACE}_file.file_imagemacro
|
||||||
|
ADD mailKey VARCHAR(20) NOT NULL COLLATE utf8_bin;
|
23
resources/sql/autopatches/20140106.macromailkey.2.php
Normal file
23
resources/sql/autopatches/20140106.macromailkey.2.php
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
echo "Adding mailkeys to macros.\n";
|
||||||
|
|
||||||
|
$table = new PhabricatorFileImageMacro();
|
||||||
|
$conn_w = $table->establishConnection('w');
|
||||||
|
$iterator = new LiskMigrationIterator($table);
|
||||||
|
foreach ($iterator as $macro) {
|
||||||
|
$id = $macro->getID();
|
||||||
|
|
||||||
|
echo "Populating macro {$id}...\n";
|
||||||
|
|
||||||
|
if (!$macro->getMailKey()) {
|
||||||
|
queryfx(
|
||||||
|
$conn_w,
|
||||||
|
'UPDATE %T SET mailKey = %s WHERE id = %d',
|
||||||
|
$table->getTableName(),
|
||||||
|
Filesystem::readRandomCharacters(20),
|
||||||
|
$id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "Done.\n";
|
|
@ -13,6 +13,7 @@ final class PhabricatorFileImageMacro extends PhabricatorFileDAO
|
||||||
protected $isDisabled = 0;
|
protected $isDisabled = 0;
|
||||||
protected $audioPHID;
|
protected $audioPHID;
|
||||||
protected $audioBehavior = self::AUDIO_BEHAVIOR_NONE;
|
protected $audioBehavior = self::AUDIO_BEHAVIOR_NONE;
|
||||||
|
protected $mailKey;
|
||||||
|
|
||||||
private $file = self::ATTACHABLE;
|
private $file = self::ATTACHABLE;
|
||||||
private $audio = self::ATTACHABLE;
|
private $audio = self::ATTACHABLE;
|
||||||
|
@ -50,10 +51,18 @@ final class PhabricatorFileImageMacro extends PhabricatorFileDAO
|
||||||
PhabricatorMacroPHIDTypeMacro::TYPECONST);
|
PhabricatorMacroPHIDTypeMacro::TYPECONST);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isAutomaticallySubscribed($phid) {
|
|
||||||
return false;
|
public function save() {
|
||||||
|
if (!$this->getMailKey()) {
|
||||||
|
$this->setMailKey(Filesystem::readRandomCharacters(20));
|
||||||
|
}
|
||||||
|
return parent::save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
|
||||||
|
|
||||||
|
|
||||||
public function getApplicationTransactionEditor() {
|
public function getApplicationTransactionEditor() {
|
||||||
return new PhabricatorMacroEditor();
|
return new PhabricatorMacroEditor();
|
||||||
}
|
}
|
||||||
|
@ -62,6 +71,18 @@ final class PhabricatorFileImageMacro extends PhabricatorFileDAO
|
||||||
return new PhabricatorMacroTransaction();
|
return new PhabricatorMacroTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* -( PhabricatorSubscribableInterface )----------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
public function isAutomaticallySubscribed($phid) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
public function getCapabilities() {
|
public function getCapabilities() {
|
||||||
return array(
|
return array(
|
||||||
PhabricatorPolicyCapability::CAN_VIEW,
|
PhabricatorPolicyCapability::CAN_VIEW,
|
||||||
|
|
Loading…
Reference in a new issue