Skip to content

Commit 5aa159a

Browse files
author
epriestley
committedMay 25, 2022
Pass "object" to modular transaction methods explicitly
Summary: Ref T13682. When editing a comment, the edit pathway may invoke file PHID extraction without first formalizing an object on the Editor. Pass the "object" explicitly to generally improve the robustness of this pathway. Test Plan: Edited a comment. Maniphest Tasks: T13682 Differential Revision: https://secure.phabricator.com/D21839
1 parent 8e703c8 commit 5aa159a

File tree

1 file changed

+27
-21
lines changed

1 file changed

+27
-21
lines changed
 

‎src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php

+27-21
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ private function adjustTransactionValues(
398398
$new = $xaction->getNewValue();
399399

400400
$type = $xaction->getTransactionType();
401-
$xtype = $this->getModularTransactionType($type);
401+
$xtype = $this->getModularTransactionType($object, $type);
402402
if ($xtype) {
403403
$xtype = clone $xtype;
404404
$xtype->setStorage($xaction);
@@ -493,7 +493,7 @@ private function getTransactionOldValue(
493493

494494
$type = $xaction->getTransactionType();
495495

496-
$xtype = $this->getModularTransactionType($type);
496+
$xtype = $this->getModularTransactionType($object, $type);
497497
if ($xtype) {
498498
$xtype = clone $xtype;
499499
$xtype->setStorage($xaction);
@@ -591,7 +591,7 @@ private function getTransactionNewValue(
591591

592592
$type = $xaction->getTransactionType();
593593

594-
$xtype = $this->getModularTransactionType($type);
594+
$xtype = $this->getModularTransactionType($object, $type);
595595
if ($xtype) {
596596
$xtype = clone $xtype;
597597
$xtype->setStorage($xaction);
@@ -712,7 +712,7 @@ protected function transactionHasEffect(
712712
}
713713

714714
$type = $xaction->getTransactionType();
715-
$xtype = $this->getModularTransactionType($type);
715+
$xtype = $this->getModularTransactionType($object, $type);
716716
if ($xtype) {
717717
return $xtype->getTransactionHasEffect(
718718
$object,
@@ -745,7 +745,7 @@ private function applyInternalEffects(
745745

746746
$type = $xaction->getTransactionType();
747747

748-
$xtype = $this->getModularTransactionType($type);
748+
$xtype = $this->getModularTransactionType($object, $type);
749749
if ($xtype) {
750750
$xtype = clone $xtype;
751751
$xtype->setStorage($xaction);
@@ -783,7 +783,7 @@ private function applyExternalEffects(
783783

784784
$type = $xaction->getTransactionType();
785785

786-
$xtype = $this->getModularTransactionType($type);
786+
$xtype = $this->getModularTransactionType($object, $type);
787787
if ($xtype) {
788788
$xtype = clone $xtype;
789789
$xtype->setStorage($xaction);
@@ -1120,7 +1120,7 @@ final protected function didCommitTransactions(
11201120
continue;
11211121
}
11221122

1123-
$xtype = $this->getModularTransactionType($type);
1123+
$xtype = $this->getModularTransactionType($object, $type);
11241124
if (!$xtype) {
11251125
continue;
11261126
}
@@ -1861,7 +1861,7 @@ private function applyCapabilityChecks(
18611861
foreach ($xactions as $xaction) {
18621862
$type = $xaction->getTransactionType();
18631863

1864-
$xtype = $this->getModularTransactionType($type);
1864+
$xtype = $this->getModularTransactionType($object, $type);
18651865
if (!$xtype) {
18661866
$capabilities = $this->getLegacyRequiredCapabilities($xaction);
18671867
} else {
@@ -2136,11 +2136,11 @@ protected function mergeTransactions(
21362136
PhabricatorApplicationTransaction $u,
21372137
PhabricatorApplicationTransaction $v) {
21382138

2139+
$object = $this->object;
21392140
$type = $u->getTransactionType();
21402141

2141-
$xtype = $this->getModularTransactionType($type);
2142+
$xtype = $this->getModularTransactionType($object, $type);
21422143
if ($xtype) {
2143-
$object = $this->object;
21442144
return $xtype->mergeTransactions($object, $u, $v);
21452145
}
21462146

@@ -2866,7 +2866,7 @@ protected function validateTransaction(
28662866

28672867
$errors = array();
28682868

2869-
$xtype = $this->getModularTransactionType($type);
2869+
$xtype = $this->getModularTransactionType($object, $type);
28702870
if ($xtype) {
28712871
$errors[] = $xtype->validateTransactions($object, $xactions);
28722872
}
@@ -4009,8 +4009,9 @@ protected function addHeadersAndCommentsToMailBody(
40094009

40104010
private function getMailDiffSectionHeader($xaction) {
40114011
$type = $xaction->getTransactionType();
4012+
$object = $this->object;
40124013

4013-
$xtype = $this->getModularTransactionType($type);
4014+
$xtype = $this->getModularTransactionType($object, $type);
40144015
if ($xtype) {
40154016
return $xtype->getMailDiffSectionHeader();
40164017
}
@@ -4408,7 +4409,7 @@ private function extractFilePHIDs(
44084409
foreach ($xactions as $xaction) {
44094410
$type = $xaction->getTransactionType();
44104411

4411-
$xtype = $this->getModularTransactionType($type);
4412+
$xtype = $this->getModularTransactionType($object, $type);
44124413
if ($xtype) {
44134414
$phids[] = $xtype->extractFilePHIDs($object, $xaction->getNewValue());
44144415
} else {
@@ -4954,9 +4955,11 @@ private function updateWorkboardColumns($object, $const, $old, $new) {
49544955
$proxy_phids);
49554956
}
49564957

4957-
private function getModularTransactionTypes() {
4958+
private function getModularTransactionTypes(
4959+
PhabricatorLiskDAO $object) {
4960+
49584961
if ($this->modularTypes === null) {
4959-
$template = $this->object->getApplicationTransactionTemplate();
4962+
$template = $object->getApplicationTransactionTemplate();
49604963
if ($template instanceof PhabricatorModularTransaction) {
49614964
$xtypes = $template->newModularTransactionTypes();
49624965
foreach ($xtypes as $key => $xtype) {
@@ -4974,8 +4977,8 @@ private function getModularTransactionTypes() {
49744977
return $this->modularTypes;
49754978
}
49764979

4977-
private function getModularTransactionType($type) {
4978-
$types = $this->getModularTransactionTypes();
4980+
private function getModularTransactionType($object, $type) {
4981+
$types = $this->getModularTransactionTypes($object);
49794982
return idx($types, $type);
49804983
}
49814984

@@ -5535,7 +5538,7 @@ private function newMFATransactions(
55355538
foreach ($xactions as $xaction) {
55365539
$type = $xaction->getTransactionType();
55375540

5538-
$xtype = $this->getModularTransactionType($type);
5541+
$xtype = $this->getModularTransactionType($object, $type);
55395542
if ($xtype) {
55405543
$xtype = clone $xtype;
55415544
$xtype->setStorage($xaction);
@@ -5582,8 +5585,9 @@ private function newMFATransactions(
55825585
private function getTitleForTextMail(
55835586
PhabricatorApplicationTransaction $xaction) {
55845587
$type = $xaction->getTransactionType();
5588+
$object = $this->object;
55855589

5586-
$xtype = $this->getModularTransactionType($type);
5590+
$xtype = $this->getModularTransactionType($object, $type);
55875591
if ($xtype) {
55885592
$xtype = clone $xtype;
55895593
$xtype->setStorage($xaction);
@@ -5599,8 +5603,9 @@ private function getTitleForTextMail(
55995603
private function getTitleForHTMLMail(
56005604
PhabricatorApplicationTransaction $xaction) {
56015605
$type = $xaction->getTransactionType();
5606+
$object = $this->object;
56025607

5603-
$xtype = $this->getModularTransactionType($type);
5608+
$xtype = $this->getModularTransactionType($object, $type);
56045609
if ($xtype) {
56055610
$xtype = clone $xtype;
56065611
$xtype->setStorage($xaction);
@@ -5617,8 +5622,9 @@ private function getTitleForHTMLMail(
56175622
private function getBodyForTextMail(
56185623
PhabricatorApplicationTransaction $xaction) {
56195624
$type = $xaction->getTransactionType();
5625+
$object = $this->object;
56205626

5621-
$xtype = $this->getModularTransactionType($type);
5627+
$xtype = $this->getModularTransactionType($object, $type);
56225628
if ($xtype) {
56235629
$xtype = clone $xtype;
56245630
$xtype->setStorage($xaction);

0 commit comments

Comments
 (0)
Failed to load comments.