@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Guarantee that fields copied from diffs persist on revisions

Summary:
Fixes T4636. Currently, we copy fields from the diff to the revision during the external effect phase, but there's no guarantee that we persist the object after this phase.

(In practice, when Herald rules trigger they cause the object to persist on this install, which is why we don't see this issue.)

Instead, move the field copies to the internal phase, where persistence is guaranteed.

Also consolidate some of the diff loading.

Test Plan: Ran `arc diff`.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: mbishopim3, epriestley

Maniphest Tasks: T4636

Differential Revision: https://secure.phabricator.com/D8610

+26 -19
+26 -19
src/applications/differential/editor/DifferentialTransactionEditor.php
··· 183 183 ($object->getStatus() == $status_plan))) { 184 184 $object->setStatus($status_review); 185 185 } 186 + 187 + $diff = $this->requireDiff($xaction->getNewValue()); 188 + 189 + $object->setLineCount($diff->getLineCount()); 190 + $object->setRepositoryPHID($diff->getRepositoryPHID()); 191 + $object->setArcanistProjectPHID($diff->getArcanistProjectPHID()); 192 + 186 193 // TODO: Update the `diffPHID` once we add that. 187 194 return; 188 195 case DifferentialTransaction::TYPE_ACTION: ··· 304 311 305 312 $maniphest = 'PhabricatorApplicationManiphest'; 306 313 if (PhabricatorApplication::isClassInstalled($maniphest)) { 307 - $diff = $this->loadDiff($xaction->getNewValue()); 314 + $diff = $this->requireDiff($xaction->getNewValue()); 308 315 $branch = $diff->getBranch(); 309 316 310 317 // No "$", to allow for branches like T123_demo. ··· 475 482 return; 476 483 case DifferentialTransaction::TYPE_UPDATE: 477 484 // Now that we're inside the transaction, do a final check. 478 - $diff = $this->loadDiff($xaction->getNewValue()); 485 + $diff = $this->requireDiff($xaction->getNewValue()); 479 486 480 487 // TODO: It would be slightly cleaner to just revalidate this 481 488 // transaction somehow using the same validation code, but that's 482 489 // not easy to do at the moment. 483 490 484 - if (!$diff) { 485 - throw new Exception(pht('Diff does not exist!')); 486 - } else { 487 - $revision_id = $diff->getRevisionID(); 488 - if ($revision_id && ($revision_id != $object->getID())) { 489 - throw new Exception( 490 - pht( 491 - 'Diff is already attached to another revision. You lost '. 492 - 'a race?')); 493 - } 491 + $revision_id = $diff->getRevisionID(); 492 + if ($revision_id && ($revision_id != $object->getID())) { 493 + throw new Exception( 494 + pht( 495 + 'Diff is already attached to another revision. You lost '. 496 + 'a race?')); 494 497 } 495 498 496 499 $diff->setRevisionID($object->getID()); 497 500 $diff->save(); 498 - 499 - $object->setLineCount($diff->getLineCount()); 500 - $object->setRepositoryPHID($diff->getRepositoryPHID()); 501 - $object->setArcanistProjectPHID($diff->getArcanistProjectPHID()); 502 - 503 501 return; 504 502 } 505 503 ··· 560 558 foreach ($xactions as $xaction) { 561 559 switch ($xaction->getTransactionType()) { 562 560 case DifferentialTransaction::TYPE_UPDATE: 563 - $diff = $this->loadDiff($xaction->getNewValue(), true); 561 + $diff = $this->requireDiff($xaction->getNewValue(), true); 564 562 565 563 // Update these denormalized index tables when we attach a new 566 564 // diff to a revision. ··· 1122 1120 } 1123 1121 1124 1122 if ($update_xaction) { 1125 - $diff = $this->loadDiff($update_xaction->getNewValue(), true); 1123 + $diff = $this->requireDiff($update_xaction->getNewValue(), true); 1126 1124 1127 1125 $body->addTextSection( 1128 1126 pht('AFFECTED FILES'), ··· 1322 1320 } 1323 1321 1324 1322 return $query->executeOne(); 1323 + } 1324 + 1325 + private function requireDiff($phid, $need_changesets = false) { 1326 + $diff = $this->loadDiff($phid, $need_changesets); 1327 + if (!$diff) { 1328 + throw new Exception(pht('Diff "%s" does not exist!', $phid)); 1329 + } 1330 + 1331 + return $diff; 1325 1332 } 1326 1333 1327 1334 /* -( Herald Integration )------------------------------------------------- */