Page MenuHomePhabricator

D16522.id.diff
No OneTemporary

D16522.id.diff

diff --git a/src/applications/audit/editor/PhabricatorAuditEditor.php b/src/applications/audit/editor/PhabricatorAuditEditor.php
--- a/src/applications/audit/editor/PhabricatorAuditEditor.php
+++ b/src/applications/audit/editor/PhabricatorAuditEditor.php
@@ -886,9 +886,8 @@
protected function buildHeraldAdapter(
PhabricatorLiskDAO $object,
array $xactions) {
-
return id(new HeraldCommitAdapter())
- ->setCommit($object);
+ ->setObject($object);
}
protected function didApplyHeraldRules(
diff --git a/src/applications/differential/herald/HeraldDifferentialRevisionAdapter.php b/src/applications/differential/herald/HeraldDifferentialRevisionAdapter.php
--- a/src/applications/differential/herald/HeraldDifferentialRevisionAdapter.php
+++ b/src/applications/differential/herald/HeraldDifferentialRevisionAdapter.php
@@ -29,7 +29,7 @@
'Test rules which run when a revision is created or updated.');
}
- public function newTestAdapter($object) {
+ public function newTestAdapter(PhabricatorUser $viewer, $object) {
return self::newLegacyAdapter(
$object,
$object->loadActiveDiff());
diff --git a/src/applications/diffusion/herald/HeraldCommitAdapter.php b/src/applications/diffusion/herald/HeraldCommitAdapter.php
--- a/src/applications/diffusion/herald/HeraldCommitAdapter.php
+++ b/src/applications/diffusion/herald/HeraldCommitAdapter.php
@@ -8,7 +8,6 @@
protected $revision;
protected $commit;
- protected $commitData;
private $commitDiff;
protected $affectedPaths;
@@ -35,6 +34,23 @@
'Test rules which run after a commit is discovered and imported.');
}
+ public function newTestAdapter(PhabricatorUser $viewer, $object) {
+ $object = id(new DiffusionCommitQuery())
+ ->setViewer($viewer)
+ ->withPHIDs(array($object->getPHID()))
+ ->needCommitData(true)
+ ->executeOne();
+ if (!$object) {
+ throw new Exception(
+ pht(
+ 'Failed to reload commit ("%s") to fetch commit data.',
+ $object->getPHID()));
+ }
+
+ return id(clone $this)
+ ->setObject($object);
+ }
+
protected function initializeNewAdapter() {
$this->commit = $this->newObject();
}
@@ -100,33 +116,6 @@
return pht('This rule can trigger for **repositories** and **projects**.');
}
- public function setCommit(PhabricatorRepositoryCommit $commit) {
- $viewer = PhabricatorUser::getOmnipotentUser();
-
- $repository = id(new PhabricatorRepositoryQuery())
- ->setViewer($viewer)
- ->withIDs(array($commit->getRepositoryID()))
- ->executeOne();
- if (!$repository) {
- throw new Exception(pht('Unable to load repository!'));
- }
-
- $data = id(new PhabricatorRepositoryCommitData())->loadOneWhere(
- 'commitID = %d',
- $commit->getID());
- if (!$data) {
- throw new Exception(pht('Unable to load commit data!'));
- }
-
- $this->commit = clone $commit;
- $this->commit->attachRepository($repository);
- $this->commit->attachCommitData($data);
-
- $this->commitData = $data;
-
- return $this;
- }
-
public function getHeraldName() {
return $this->commit->getMonogram();
}
@@ -171,7 +160,10 @@
public function loadDifferentialRevision() {
if ($this->affectedRevision === null) {
$this->affectedRevision = false;
- $data = $this->commitData;
+
+ $commit = $this->getObject();
+ $data = $commit->getCommitData();
+
$revision_id = $data->getCommitDetail('differential.revisionID');
if ($revision_id) {
// NOTE: The Herald rule owner might not actually have access to
diff --git a/src/applications/herald/adapter/HeraldAdapter.php b/src/applications/herald/adapter/HeraldAdapter.php
--- a/src/applications/herald/adapter/HeraldAdapter.php
+++ b/src/applications/herald/adapter/HeraldAdapter.php
@@ -224,7 +224,7 @@
return $this->isTestAdapterForObject($object);
}
- public function newTestAdapter($object) {
+ public function newTestAdapter(PhabricatorUser $viewer, $object) {
return id(clone $this)
->setObject($object);
}
diff --git a/src/applications/herald/controller/HeraldTestConsoleController.php b/src/applications/herald/controller/HeraldTestConsoleController.php
--- a/src/applications/herald/controller/HeraldTestConsoleController.php
+++ b/src/applications/herald/controller/HeraldTestConsoleController.php
@@ -142,7 +142,9 @@
if ($request->isFormPost() && $adapter_key) {
if (isset($can_select[$adapter_key])) {
- $adapter = $can_select[$adapter_key]->newTestAdapter($object);
+ $adapter = $can_select[$adapter_key]->newTestAdapter(
+ $viewer,
+ $object);
$this->setTestAdapter($adapter);
return null;
}

File Metadata

Mime Type
text/plain
Expires
Fri, Mar 21, 9:40 PM (2 w, 14 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7661993
Default Alt Text
D16522.id.diff (4 KB)

Event Timeline