mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-29 10:12:41 +01:00
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
This commit is contained in:
parent
8e703c8c35
commit
5aa159a830
1 changed files with 27 additions and 21 deletions
|
@ -398,7 +398,7 @@ abstract class PhabricatorApplicationTransactionEditor
|
||||||
$new = $xaction->getNewValue();
|
$new = $xaction->getNewValue();
|
||||||
|
|
||||||
$type = $xaction->getTransactionType();
|
$type = $xaction->getTransactionType();
|
||||||
$xtype = $this->getModularTransactionType($type);
|
$xtype = $this->getModularTransactionType($object, $type);
|
||||||
if ($xtype) {
|
if ($xtype) {
|
||||||
$xtype = clone $xtype;
|
$xtype = clone $xtype;
|
||||||
$xtype->setStorage($xaction);
|
$xtype->setStorage($xaction);
|
||||||
|
@ -493,7 +493,7 @@ abstract class PhabricatorApplicationTransactionEditor
|
||||||
|
|
||||||
$type = $xaction->getTransactionType();
|
$type = $xaction->getTransactionType();
|
||||||
|
|
||||||
$xtype = $this->getModularTransactionType($type);
|
$xtype = $this->getModularTransactionType($object, $type);
|
||||||
if ($xtype) {
|
if ($xtype) {
|
||||||
$xtype = clone $xtype;
|
$xtype = clone $xtype;
|
||||||
$xtype->setStorage($xaction);
|
$xtype->setStorage($xaction);
|
||||||
|
@ -591,7 +591,7 @@ abstract class PhabricatorApplicationTransactionEditor
|
||||||
|
|
||||||
$type = $xaction->getTransactionType();
|
$type = $xaction->getTransactionType();
|
||||||
|
|
||||||
$xtype = $this->getModularTransactionType($type);
|
$xtype = $this->getModularTransactionType($object, $type);
|
||||||
if ($xtype) {
|
if ($xtype) {
|
||||||
$xtype = clone $xtype;
|
$xtype = clone $xtype;
|
||||||
$xtype->setStorage($xaction);
|
$xtype->setStorage($xaction);
|
||||||
|
@ -712,7 +712,7 @@ abstract class PhabricatorApplicationTransactionEditor
|
||||||
}
|
}
|
||||||
|
|
||||||
$type = $xaction->getTransactionType();
|
$type = $xaction->getTransactionType();
|
||||||
$xtype = $this->getModularTransactionType($type);
|
$xtype = $this->getModularTransactionType($object, $type);
|
||||||
if ($xtype) {
|
if ($xtype) {
|
||||||
return $xtype->getTransactionHasEffect(
|
return $xtype->getTransactionHasEffect(
|
||||||
$object,
|
$object,
|
||||||
|
@ -745,7 +745,7 @@ abstract class PhabricatorApplicationTransactionEditor
|
||||||
|
|
||||||
$type = $xaction->getTransactionType();
|
$type = $xaction->getTransactionType();
|
||||||
|
|
||||||
$xtype = $this->getModularTransactionType($type);
|
$xtype = $this->getModularTransactionType($object, $type);
|
||||||
if ($xtype) {
|
if ($xtype) {
|
||||||
$xtype = clone $xtype;
|
$xtype = clone $xtype;
|
||||||
$xtype->setStorage($xaction);
|
$xtype->setStorage($xaction);
|
||||||
|
@ -783,7 +783,7 @@ abstract class PhabricatorApplicationTransactionEditor
|
||||||
|
|
||||||
$type = $xaction->getTransactionType();
|
$type = $xaction->getTransactionType();
|
||||||
|
|
||||||
$xtype = $this->getModularTransactionType($type);
|
$xtype = $this->getModularTransactionType($object, $type);
|
||||||
if ($xtype) {
|
if ($xtype) {
|
||||||
$xtype = clone $xtype;
|
$xtype = clone $xtype;
|
||||||
$xtype->setStorage($xaction);
|
$xtype->setStorage($xaction);
|
||||||
|
@ -1120,7 +1120,7 @@ abstract class PhabricatorApplicationTransactionEditor
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$xtype = $this->getModularTransactionType($type);
|
$xtype = $this->getModularTransactionType($object, $type);
|
||||||
if (!$xtype) {
|
if (!$xtype) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1861,7 +1861,7 @@ abstract class PhabricatorApplicationTransactionEditor
|
||||||
foreach ($xactions as $xaction) {
|
foreach ($xactions as $xaction) {
|
||||||
$type = $xaction->getTransactionType();
|
$type = $xaction->getTransactionType();
|
||||||
|
|
||||||
$xtype = $this->getModularTransactionType($type);
|
$xtype = $this->getModularTransactionType($object, $type);
|
||||||
if (!$xtype) {
|
if (!$xtype) {
|
||||||
$capabilities = $this->getLegacyRequiredCapabilities($xaction);
|
$capabilities = $this->getLegacyRequiredCapabilities($xaction);
|
||||||
} else {
|
} else {
|
||||||
|
@ -2136,11 +2136,11 @@ abstract class PhabricatorApplicationTransactionEditor
|
||||||
PhabricatorApplicationTransaction $u,
|
PhabricatorApplicationTransaction $u,
|
||||||
PhabricatorApplicationTransaction $v) {
|
PhabricatorApplicationTransaction $v) {
|
||||||
|
|
||||||
|
$object = $this->object;
|
||||||
$type = $u->getTransactionType();
|
$type = $u->getTransactionType();
|
||||||
|
|
||||||
$xtype = $this->getModularTransactionType($type);
|
$xtype = $this->getModularTransactionType($object, $type);
|
||||||
if ($xtype) {
|
if ($xtype) {
|
||||||
$object = $this->object;
|
|
||||||
return $xtype->mergeTransactions($object, $u, $v);
|
return $xtype->mergeTransactions($object, $u, $v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2866,7 +2866,7 @@ abstract class PhabricatorApplicationTransactionEditor
|
||||||
|
|
||||||
$errors = array();
|
$errors = array();
|
||||||
|
|
||||||
$xtype = $this->getModularTransactionType($type);
|
$xtype = $this->getModularTransactionType($object, $type);
|
||||||
if ($xtype) {
|
if ($xtype) {
|
||||||
$errors[] = $xtype->validateTransactions($object, $xactions);
|
$errors[] = $xtype->validateTransactions($object, $xactions);
|
||||||
}
|
}
|
||||||
|
@ -4009,8 +4009,9 @@ abstract class PhabricatorApplicationTransactionEditor
|
||||||
|
|
||||||
private function getMailDiffSectionHeader($xaction) {
|
private function getMailDiffSectionHeader($xaction) {
|
||||||
$type = $xaction->getTransactionType();
|
$type = $xaction->getTransactionType();
|
||||||
|
$object = $this->object;
|
||||||
|
|
||||||
$xtype = $this->getModularTransactionType($type);
|
$xtype = $this->getModularTransactionType($object, $type);
|
||||||
if ($xtype) {
|
if ($xtype) {
|
||||||
return $xtype->getMailDiffSectionHeader();
|
return $xtype->getMailDiffSectionHeader();
|
||||||
}
|
}
|
||||||
|
@ -4408,7 +4409,7 @@ abstract class PhabricatorApplicationTransactionEditor
|
||||||
foreach ($xactions as $xaction) {
|
foreach ($xactions as $xaction) {
|
||||||
$type = $xaction->getTransactionType();
|
$type = $xaction->getTransactionType();
|
||||||
|
|
||||||
$xtype = $this->getModularTransactionType($type);
|
$xtype = $this->getModularTransactionType($object, $type);
|
||||||
if ($xtype) {
|
if ($xtype) {
|
||||||
$phids[] = $xtype->extractFilePHIDs($object, $xaction->getNewValue());
|
$phids[] = $xtype->extractFilePHIDs($object, $xaction->getNewValue());
|
||||||
} else {
|
} else {
|
||||||
|
@ -4954,9 +4955,11 @@ abstract class PhabricatorApplicationTransactionEditor
|
||||||
$proxy_phids);
|
$proxy_phids);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getModularTransactionTypes() {
|
private function getModularTransactionTypes(
|
||||||
|
PhabricatorLiskDAO $object) {
|
||||||
|
|
||||||
if ($this->modularTypes === null) {
|
if ($this->modularTypes === null) {
|
||||||
$template = $this->object->getApplicationTransactionTemplate();
|
$template = $object->getApplicationTransactionTemplate();
|
||||||
if ($template instanceof PhabricatorModularTransaction) {
|
if ($template instanceof PhabricatorModularTransaction) {
|
||||||
$xtypes = $template->newModularTransactionTypes();
|
$xtypes = $template->newModularTransactionTypes();
|
||||||
foreach ($xtypes as $key => $xtype) {
|
foreach ($xtypes as $key => $xtype) {
|
||||||
|
@ -4974,8 +4977,8 @@ abstract class PhabricatorApplicationTransactionEditor
|
||||||
return $this->modularTypes;
|
return $this->modularTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getModularTransactionType($type) {
|
private function getModularTransactionType($object, $type) {
|
||||||
$types = $this->getModularTransactionTypes();
|
$types = $this->getModularTransactionTypes($object);
|
||||||
return idx($types, $type);
|
return idx($types, $type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5535,7 +5538,7 @@ abstract class PhabricatorApplicationTransactionEditor
|
||||||
foreach ($xactions as $xaction) {
|
foreach ($xactions as $xaction) {
|
||||||
$type = $xaction->getTransactionType();
|
$type = $xaction->getTransactionType();
|
||||||
|
|
||||||
$xtype = $this->getModularTransactionType($type);
|
$xtype = $this->getModularTransactionType($object, $type);
|
||||||
if ($xtype) {
|
if ($xtype) {
|
||||||
$xtype = clone $xtype;
|
$xtype = clone $xtype;
|
||||||
$xtype->setStorage($xaction);
|
$xtype->setStorage($xaction);
|
||||||
|
@ -5582,8 +5585,9 @@ abstract class PhabricatorApplicationTransactionEditor
|
||||||
private function getTitleForTextMail(
|
private function getTitleForTextMail(
|
||||||
PhabricatorApplicationTransaction $xaction) {
|
PhabricatorApplicationTransaction $xaction) {
|
||||||
$type = $xaction->getTransactionType();
|
$type = $xaction->getTransactionType();
|
||||||
|
$object = $this->object;
|
||||||
|
|
||||||
$xtype = $this->getModularTransactionType($type);
|
$xtype = $this->getModularTransactionType($object, $type);
|
||||||
if ($xtype) {
|
if ($xtype) {
|
||||||
$xtype = clone $xtype;
|
$xtype = clone $xtype;
|
||||||
$xtype->setStorage($xaction);
|
$xtype->setStorage($xaction);
|
||||||
|
@ -5599,8 +5603,9 @@ abstract class PhabricatorApplicationTransactionEditor
|
||||||
private function getTitleForHTMLMail(
|
private function getTitleForHTMLMail(
|
||||||
PhabricatorApplicationTransaction $xaction) {
|
PhabricatorApplicationTransaction $xaction) {
|
||||||
$type = $xaction->getTransactionType();
|
$type = $xaction->getTransactionType();
|
||||||
|
$object = $this->object;
|
||||||
|
|
||||||
$xtype = $this->getModularTransactionType($type);
|
$xtype = $this->getModularTransactionType($object, $type);
|
||||||
if ($xtype) {
|
if ($xtype) {
|
||||||
$xtype = clone $xtype;
|
$xtype = clone $xtype;
|
||||||
$xtype->setStorage($xaction);
|
$xtype->setStorage($xaction);
|
||||||
|
@ -5617,8 +5622,9 @@ abstract class PhabricatorApplicationTransactionEditor
|
||||||
private function getBodyForTextMail(
|
private function getBodyForTextMail(
|
||||||
PhabricatorApplicationTransaction $xaction) {
|
PhabricatorApplicationTransaction $xaction) {
|
||||||
$type = $xaction->getTransactionType();
|
$type = $xaction->getTransactionType();
|
||||||
|
$object = $this->object;
|
||||||
|
|
||||||
$xtype = $this->getModularTransactionType($type);
|
$xtype = $this->getModularTransactionType($object, $type);
|
||||||
if ($xtype) {
|
if ($xtype) {
|
||||||
$xtype = clone $xtype;
|
$xtype = clone $xtype;
|
||||||
$xtype->setStorage($xaction);
|
$xtype->setStorage($xaction);
|
||||||
|
|
Loading…
Reference in a new issue