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

Fix an issue where some Differential edit pathways may not have reviewers attached

Summary:
Depends on D19021. Ref T13053. When you "Subscribe", or make some other types of edits, we don't necessarily have reviewer data, but may now need it to do the new recipient list logic.

I don't have a totally clean way to deal with this in the general case in mind, but just load it for now so that things don't fatal.

Test Plan: Subscribed to a revision with the "Subscribe" action.

Reviewers: amckinley

Maniphest Tasks: T13053

Differential Revision: https://secure.phabricator.com/D19022
This commit is contained in:
epriestley 2018-02-07 09:39:27 -08:00
parent 1cd3a59378
commit d0a2e3c54f
2 changed files with 29 additions and 0 deletions

View file

@ -632,6 +632,8 @@ final class DifferentialTransactionEditor
} }
protected function getMailTo(PhabricatorLiskDAO $object) { protected function getMailTo(PhabricatorLiskDAO $object) {
$this->requireReviewers($object);
$phids = array(); $phids = array();
$phids[] = $object->getAuthorPHID(); $phids[] = $object->getAuthorPHID();
foreach ($object->getReviewers() as $reviewer) { foreach ($object->getReviewers() as $reviewer) {
@ -645,6 +647,8 @@ final class DifferentialTransactionEditor
} }
protected function newMailUnexpandablePHIDs(PhabricatorLiskDAO $object) { protected function newMailUnexpandablePHIDs(PhabricatorLiskDAO $object) {
$this->requireReviewers($object);
$phids = array(); $phids = array();
foreach ($object->getReviewers() as $reviewer) { foreach ($object->getReviewers() as $reviewer) {
@ -1737,4 +1741,25 @@ final class DifferentialTransactionEditor
} }
} }
private function requireReviewers(DifferentialRevision $revision) {
if ($revision->hasAttachedReviewers()) {
return;
}
$with_reviewers = id(new DifferentialRevisionQuery())
->setViewer($this->getActor())
->needReviewers(true)
->withPHIDs(array($revision->getPHID()))
->executeOne();
if (!$with_reviewers) {
throw new Exception(
pht(
'Failed to reload revision ("%s").',
$revision->getPHID()));
}
$revision->attachReviewers($with_reviewers->getReviewers());
}
} }

View file

@ -583,6 +583,10 @@ final class DifferentialRevision extends DifferentialDAO
return $this; return $this;
} }
public function hasAttachedReviewers() {
return ($this->reviewerStatus !== self::ATTACHABLE);
}
public function getReviewerPHIDs() { public function getReviewerPHIDs() {
$reviewers = $this->getReviewers(); $reviewers = $this->getReviewers();
return mpull($reviewers, 'getReviewerPHID'); return mpull($reviewers, 'getReviewerPHID');