Differential D18801 Diff 45115 src/applications/differential/editor/DifferentialTransactionEditor.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/editor/DifferentialTransactionEditor.php
| <?php | <?php | ||||
| final class DifferentialTransactionEditor | final class DifferentialTransactionEditor | ||||
| extends PhabricatorApplicationTransactionEditor { | extends PhabricatorApplicationTransactionEditor { | ||||
| private $changedPriorToCommitURI; | private $changedPriorToCommitURI; | ||||
| private $isCloseByCommit; | private $isCloseByCommit; | ||||
| private $repositoryPHIDOverride = false; | private $repositoryPHIDOverride = false; | ||||
| private $didExpandInlineState = false; | private $didExpandInlineState = false; | ||||
| private $hasReviewTransaction = false; | private $hasReviewTransaction = false; | ||||
| private $affectedPaths; | private $affectedPaths; | ||||
| private $firstBroadcast = false; | private $firstBroadcast = false; | ||||
| private $wasDraft = false; | |||||
| public function getEditorApplicationClass() { | public function getEditorApplicationClass() { | ||||
| return 'PhabricatorDifferentialApplication'; | return 'PhabricatorDifferentialApplication'; | ||||
| } | } | ||||
| public function getEditorObjectsDescription() { | public function getEditorObjectsDescription() { | ||||
| return pht('Differential Revisions'); | return pht('Differential Revisions'); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 140 Lines • ▼ Show 20 Lines | foreach ($xactions as $xaction) { | ||||
| case DifferentialRevisionResignTransaction::TRANSACTIONTYPE: | case DifferentialRevisionResignTransaction::TRANSACTIONTYPE: | ||||
| // If we have a review transaction, we'll skip marking the user | // If we have a review transaction, we'll skip marking the user | ||||
| // as "Commented" later. This should get cleaner after T10967. | // as "Commented" later. This should get cleaner after T10967. | ||||
| $this->hasReviewTransaction = true; | $this->hasReviewTransaction = true; | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| $this->wasDraft = $object->isDraft(); | |||||
| return parent::expandTransactions($object, $xactions); | return parent::expandTransactions($object, $xactions); | ||||
| } | } | ||||
| protected function expandTransaction( | protected function expandTransaction( | ||||
| PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
| PhabricatorApplicationTransaction $xaction) { | PhabricatorApplicationTransaction $xaction) { | ||||
| $results = parent::expandTransaction($object, $xaction); | $results = parent::expandTransaction($object, $xaction); | ||||
| ▲ Show 20 Lines • Show All 1,399 Lines • ▼ Show 20 Lines | if ($object->isDraft() && $auto_undraft) { | ||||
| // to the author if it isn't already a user so that mail comes from | // to the author if it isn't already a user so that mail comes from | ||||
| // the natural author. | // the natural author. | ||||
| $acting_phid = $this->getActingAsPHID(); | $acting_phid = $this->getActingAsPHID(); | ||||
| $user_type = PhabricatorPeopleUserPHIDType::TYPECONST; | $user_type = PhabricatorPeopleUserPHIDType::TYPECONST; | ||||
| if (phid_get_type($acting_phid) != $user_type) { | if (phid_get_type($acting_phid) != $user_type) { | ||||
| $this->setActingAsPHID($author_phid); | $this->setActingAsPHID($author_phid); | ||||
| } | } | ||||
| // Mark this as the first broadcast we're sending about the revision | |||||
| // so mail can generate specially. | |||||
| $this->firstBroadcast = true; | |||||
| $xaction = $object->getApplicationTransactionTemplate() | $xaction = $object->getApplicationTransactionTemplate() | ||||
| ->setAuthorPHID($author_phid) | ->setAuthorPHID($author_phid) | ||||
| ->setTransactionType( | ->setTransactionType( | ||||
| DifferentialRevisionRequestReviewTransaction::TRANSACTIONTYPE) | DifferentialRevisionRequestReviewTransaction::TRANSACTIONTYPE) | ||||
| ->setOldValue(false) | ->setOldValue(false) | ||||
| ->setNewValue(true); | ->setNewValue(true); | ||||
| $xaction = $this->populateTransaction($object, $xaction); | $xaction = $this->populateTransaction($object, $xaction); | ||||
| Show All 11 Lines | if ($object->isDraft() && $auto_undraft) { | ||||
| ->setStatus(DifferentialRevisionStatus::NEEDS_REVIEW) | ->setStatus(DifferentialRevisionStatus::NEEDS_REVIEW) | ||||
| ->save(); | ->save(); | ||||
| $xaction->save(); | $xaction->save(); | ||||
| $object->saveTransaction(); | $object->saveTransaction(); | ||||
| $xactions[] = $xaction; | $xactions[] = $xaction; | ||||
| } | } | ||||
| } else { | } | ||||
| // If this revision is being created into some state other than "Draft", | |||||
| // this is the first broadcast and should include sections like "SUMMARY" | // If the revision is new or was a draft, and is no longer a draft, we | ||||
| // and "TEST PLAN". | // might be sending the first email about it. | ||||
| if ($this->getIsNewObject()) { | |||||
| // This might mean it was created directly into a non-draft state, or | |||||
| // it just automatically undrafted after builds finished, or a user | |||||
| // explicitly promoted it out of the draft state with an action like | |||||
| // "Request Review". | |||||
| // If we haven't sent any email about it yet, mark this email as the first | |||||
| // email so the mail gets enriched with "SUMMARY" and "TEST PLAN". | |||||
| $is_new = $this->getIsNewObject(); | |||||
| $was_draft = $this->wasDraft; | |||||
| if (!$object->isDraft() && ($was_draft || $is_new)) { | |||||
| if (!$object->getHasBroadcast()) { | |||||
| // Mark this as the first broadcast we're sending about the revision | |||||
| // so mail can generate specially. | |||||
| $this->firstBroadcast = true; | $this->firstBroadcast = true; | ||||
| $object | |||||
| ->setHasBroadcast(true) | |||||
| ->save(); | |||||
| } | } | ||||
| } | } | ||||
| return $xactions; | return $xactions; | ||||
| } | } | ||||
| private function hasActiveBuilds($object) { | private function hasActiveBuilds($object) { | ||||
| $viewer = $this->requireActor(); | $viewer = $this->requireActor(); | ||||
| Show All 11 Lines | |||||