@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.

Transactions - fix inverse edge transaction writes

Summary: Ref XXXXX. I broke things a bit in XXXXX in that if the TYPE_EDGE had an inverse transaction, we weren't correctly "doing nothing" and instead were falling back to our old every editor has to implement a no-op ways... Fix things by putting the TYPE_EDGE code in the handle external builtin function like it belongs.

Test Plan: made a comment on a task referencng a commit successfully

Reviewers: epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T6403

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

+56 -53
+56 -53
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
··· 438 438 $this->subscribers = $subscribers; 439 439 return $this->applyBuiltinExternalTransaction($object, $xaction); 440 440 441 - case PhabricatorTransactions::TYPE_EDGE: 442 - if ($this->getIsInverseEdgeEditor()) { 443 - // If we're writing an inverse edge transaction, don't actually 444 - // do anything. The initiating editor on the other side of the 445 - // transaction will take care of the edge writes. 446 - break; 447 - } 448 - 449 - $old = $xaction->getOldValue(); 450 - $new = $xaction->getNewValue(); 451 - $src = $object->getPHID(); 452 - $const = $xaction->getMetadataValue('edge:type'); 453 - 454 - $type = PhabricatorEdgeType::getByConstant($const); 455 - if ($type->shouldWriteInverseTransactions()) { 456 - $this->applyInverseEdgeTransactions( 457 - $object, 458 - $xaction, 459 - $type->getInverseEdgeConstant()); 460 - } 461 - 462 - foreach ($new as $dst_phid => $edge) { 463 - $new[$dst_phid]['src'] = $src; 464 - } 465 - 466 - $editor = new PhabricatorEdgeEditor(); 467 - 468 - foreach ($old as $dst_phid => $edge) { 469 - if (!empty($new[$dst_phid])) { 470 - if ($old[$dst_phid]['data'] === $new[$dst_phid]['data']) { 471 - continue; 472 - } 473 - } 474 - $editor->removeEdge($src, $const, $dst_phid); 475 - } 476 - 477 - foreach ($new as $dst_phid => $edge) { 478 - if (!empty($old[$dst_phid])) { 479 - if ($old[$dst_phid]['data'] === $new[$dst_phid]['data']) { 480 - continue; 481 - } 482 - } 483 - 484 - $data = array( 485 - 'data' => $edge['data'], 486 - ); 487 - 488 - $editor->addEdge($src, $const, $dst_phid, $data); 489 - } 490 - 491 - $editor->save(); 492 - return $this->applyBuiltinExternalTransaction($object, $xaction); 493 441 case PhabricatorTransactions::TYPE_CUSTOMFIELD: 494 442 $field = $this->getCustomFieldForTransaction($object, $xaction); 495 443 return $field->applyApplicationTransactionExternalEffects($xaction); 444 + case PhabricatorTransactions::TYPE_EDGE: 496 445 case PhabricatorTransactions::TYPE_VIEW_POLICY: 497 446 case PhabricatorTransactions::TYPE_EDIT_POLICY: 498 447 case PhabricatorTransactions::TYPE_JOIN_POLICY: ··· 547 496 protected function applyBuiltinExternalTransaction( 548 497 PhabricatorLiskDAO $object, 549 498 PhabricatorApplicationTransaction $xaction) { 550 - return; 499 + 500 + switch ($xaction->getTransactionType()) { 501 + case PhabricatorTransactions::TYPE_EDGE: 502 + if ($this->getIsInverseEdgeEditor()) { 503 + // If we're writing an inverse edge transaction, don't actually 504 + // do anything. The initiating editor on the other side of the 505 + // transaction will take care of the edge writes. 506 + break; 507 + } 508 + 509 + $old = $xaction->getOldValue(); 510 + $new = $xaction->getNewValue(); 511 + $src = $object->getPHID(); 512 + $const = $xaction->getMetadataValue('edge:type'); 513 + 514 + $type = PhabricatorEdgeType::getByConstant($const); 515 + if ($type->shouldWriteInverseTransactions()) { 516 + $this->applyInverseEdgeTransactions( 517 + $object, 518 + $xaction, 519 + $type->getInverseEdgeConstant()); 520 + } 521 + 522 + foreach ($new as $dst_phid => $edge) { 523 + $new[$dst_phid]['src'] = $src; 524 + } 525 + 526 + $editor = new PhabricatorEdgeEditor(); 527 + 528 + foreach ($old as $dst_phid => $edge) { 529 + if (!empty($new[$dst_phid])) { 530 + if ($old[$dst_phid]['data'] === $new[$dst_phid]['data']) { 531 + continue; 532 + } 533 + } 534 + $editor->removeEdge($src, $const, $dst_phid); 535 + } 536 + 537 + foreach ($new as $dst_phid => $edge) { 538 + if (!empty($old[$dst_phid])) { 539 + if ($old[$dst_phid]['data'] === $new[$dst_phid]['data']) { 540 + continue; 541 + } 542 + } 543 + 544 + $data = array( 545 + 'data' => $edge['data'], 546 + ); 547 + 548 + $editor->addEdge($src, $const, $dst_phid, $data); 549 + } 550 + 551 + $editor->save(); 552 + break; 553 + } 551 554 } 552 555 553 556 /**