diff --git a/resources/sql/patches/034.savedheader.sql b/resources/sql/patches/034.savedheader.sql new file mode 100644 index 0000000000..658ee371ad --- /dev/null +++ b/resources/sql/patches/034.savedheader.sql @@ -0,0 +1,4 @@ +CREATE TABLE phabricator_herald.herald_savedheader ( + phid varchar(64) binary not null primary key, + header varchar(255) not null +) ENGINE=InnoDB; \ No newline at end of file diff --git a/src/applications/differential/editor/comment/DifferentialCommentEditor.php b/src/applications/differential/editor/comment/DifferentialCommentEditor.php index e897f61fb0..7fb98ee6c4 100644 --- a/src/applications/differential/editor/comment/DifferentialCommentEditor.php +++ b/src/applications/differential/editor/comment/DifferentialCommentEditor.php @@ -304,6 +304,9 @@ class DifferentialCommentEditor { ->loadHandles(); $actor_handle = $handles[$this->actorPHID]; + $xherald_header = HeraldTranscript::loadXHeraldRulesHeader( + $revision->getPHID()); + id(new DifferentialCommentMail( $revision, $actor_handle, @@ -316,6 +319,7 @@ class DifferentialCommentEditor { array($revision->getAuthorPHID()))) ->setCCPHIDs($revision->getCCPHIDs()) ->setChangedByCommit($this->getChangedByCommit()) + ->setXHeraldRulesHeader($xherald_header) ->send(); $event_data = array( diff --git a/src/applications/differential/editor/comment/__init__.php b/src/applications/differential/editor/comment/__init__.php index b18b5491bb..ef928ffd41 100644 --- a/src/applications/differential/editor/comment/__init__.php +++ b/src/applications/differential/editor/comment/__init__.php @@ -13,6 +13,7 @@ phutil_require_module('phabricator', 'applications/differential/mail/comment'); phutil_require_module('phabricator', 'applications/differential/storage/changeset'); phutil_require_module('phabricator', 'applications/differential/storage/comment'); phutil_require_module('phabricator', 'applications/differential/storage/inlinecomment'); +phutil_require_module('phabricator', 'applications/herald/storage/transcript/base'); phutil_require_module('phabricator', 'applications/phid/handle/data'); phutil_require_module('phabricator', 'infrastructure/daemon/timeline/storage/event'); diff --git a/src/applications/differential/editor/revision/DifferentialRevisionEditor.php b/src/applications/differential/editor/revision/DifferentialRevisionEditor.php index 272b529743..3e19e25d44 100644 --- a/src/applications/differential/editor/revision/DifferentialRevisionEditor.php +++ b/src/applications/differential/editor/revision/DifferentialRevisionEditor.php @@ -212,6 +212,10 @@ class DifferentialRevisionEditor { $xscript_phid = $xscript->getPHID(); $xscript_header = $xscript->getXHeraldRulesHeader(); + HeraldTranscript::saveXHeraldRulesHeader( + $revision->getPHID(), + $xscript_header); + $sub = array( 'rev' => array(), 'ccs' => $adapter->getCCsAddedByHerald(), diff --git a/src/applications/differential/editor/revision/__init__.php b/src/applications/differential/editor/revision/__init__.php index 969a88333f..e5703a1cb1 100644 --- a/src/applications/differential/editor/revision/__init__.php +++ b/src/applications/differential/editor/revision/__init__.php @@ -13,6 +13,7 @@ phutil_require_module('phabricator', 'applications/differential/storage/comment' phutil_require_module('phabricator', 'applications/differential/storage/revision'); phutil_require_module('phabricator', 'applications/herald/adapter/differential'); phutil_require_module('phabricator', 'applications/herald/engine/engine'); +phutil_require_module('phabricator', 'applications/herald/storage/transcript/base'); phutil_require_module('phabricator', 'applications/phid/handle/data'); phutil_require_module('phabricator', 'applications/search/index/indexer/differential'); phutil_require_module('phabricator', 'infrastructure/env'); diff --git a/src/applications/herald/storage/transcript/base/HeraldTranscript.php b/src/applications/herald/storage/transcript/base/HeraldTranscript.php index 7928ff0726..fc16e9ae72 100644 --- a/src/applications/herald/storage/transcript/base/HeraldTranscript.php +++ b/src/applications/herald/storage/transcript/base/HeraldTranscript.php @@ -33,6 +33,8 @@ class HeraldTranscript extends HeraldDAO { protected $objectPHID; protected $dryRun; + const TABLE_SAVED_HEADER = 'herald_savedheader'; + public function getXHeraldRulesHeader() { $ids = array(); foreach ($this->applyTranscripts as $xscript) { @@ -57,6 +59,29 @@ class HeraldTranscript extends HeraldDAO { return implode(', ', $ids); } + public static function saveXHeraldRulesHeader($phid, $header) { + queryfx( + id(new HeraldTranscript())->establishConnection('w'), + 'INSERT INTO %T (phid, header) VALUES (%s, %s) + ON DUPLICATE KEY UPDATE header = VALUES(header)', + self::TABLE_SAVED_HEADER, + $phid, + $header); + } + + public static function loadXHeraldRulesHeader($phid) { + $header = queryfx_one( + id(new HeraldTranscript())->establishConnection('r'), + 'SELECT * FROM %T WHERE phid = %s', + self::TABLE_SAVED_HEADER, + $phid); + if ($header) { + return idx($header, 'header'); + } + return null; + } + + protected function getConfiguration() { // Ugh. Too much of a mess to deal with. return array( diff --git a/src/applications/herald/storage/transcript/base/__init__.php b/src/applications/herald/storage/transcript/base/__init__.php index 3b9b170090..22965a8d63 100644 --- a/src/applications/herald/storage/transcript/base/__init__.php +++ b/src/applications/herald/storage/transcript/base/__init__.php @@ -8,6 +8,7 @@ phutil_require_module('phabricator', 'applications/herald/storage/base'); phutil_require_module('phabricator', 'applications/phid/storage/phid'); +phutil_require_module('phabricator', 'storage/queryfx'); phutil_require_module('phutil', 'utils');