1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 08:42:41 +01:00

Make sure auditors are attached to commits on new pathways

Companion change to D19022 for commits. Mentioning and subscribing to commits
can load them without audit data.
This commit is contained in:
epriestley 2018-02-09 17:09:00 -08:00
parent 9b7d5b74d4
commit c64aae052f
2 changed files with 28 additions and 0 deletions

View file

@ -490,6 +490,8 @@ final class PhabricatorAuditEditor
}
protected function getMailTo(PhabricatorLiskDAO $object) {
$this->requireAuditors($object);
$phids = array();
if ($object->getAuthorPHID()) {
@ -514,6 +516,8 @@ final class PhabricatorAuditEditor
}
protected function newMailUnexpandablePHIDs(PhabricatorLiskDAO $object) {
$this->requireAuditors($object);
$phids = array();
foreach ($object->getAudits() as $auditor) {
@ -856,4 +860,24 @@ final class PhabricatorAuditEditor
->executeOne();
}
private function requireAuditors(PhabricatorRepositoryCommit $commit) {
if ($commit->hasAttachedAudits()) {
return;
}
$with_auditors = id(new DiffusionCommitQuery())
->setViewer($this->getActor())
->needAuditRequests(true)
->withPHIDs(array($commit->getPHID()))
->executeOne();
if (!$with_auditors) {
throw new Exception(
pht(
'Failed to reload commit ("%s").',
$commit->getPHID()));
}
$commit->attachAudits($with_auditors->getAudits());
}
}

View file

@ -183,6 +183,10 @@ final class PhabricatorRepositoryCommit
return $this->assertAttached($this->audits);
}
public function hasAttachedAudits() {
return ($this->audits !== self::ATTACHABLE);
}
public function loadAndAttachAuditAuthority(
PhabricatorUser $viewer,
$actor_phid = null) {