Page MenuHomePhabricator

D16795.id40447.diff
No OneTemporary

D16795.id40447.diff

diff --git a/src/applications/calendar/controller/PhabricatorCalendarEventEditController.php b/src/applications/calendar/controller/PhabricatorCalendarEventEditController.php
--- a/src/applications/calendar/controller/PhabricatorCalendarEventEditController.php
+++ b/src/applications/calendar/controller/PhabricatorCalendarEventEditController.php
@@ -34,7 +34,17 @@
->addCancelButton($cancel_uri);
}
} else if ($event->getIsRecurring()) {
- $mode = $request->getStr('mode');
+
+ // If the user submits a comment or makes an edit via comment actions,
+ // always target only the current event. It doesn't make sense to add
+ // comments to every instance of an event, and the other actions don't
+ // make much sense to apply to all instances either.
+ if ($engine->isCommentAction()) {
+ $mode = PhabricatorCalendarEventEditEngine::MODE_THIS;
+ } else {
+ $mode = $request->getStr('mode');
+ }
+
if (!$mode) {
$form = id(new AphrontFormView())
->setViewer($viewer)
@@ -60,7 +70,6 @@
->addSubmitButton(pht('Continue'))
->addCancelButton($cancel_uri)
->setDisableWorkflowOnSubmit(true);
-
}
$engine
diff --git a/src/applications/calendar/editor/PhabricatorCalendarEventEditEngine.php b/src/applications/calendar/editor/PhabricatorCalendarEventEditEngine.php
--- a/src/applications/calendar/editor/PhabricatorCalendarEventEditEngine.php
+++ b/src/applications/calendar/editor/PhabricatorCalendarEventEditEngine.php
@@ -295,7 +295,7 @@
protected function willApplyTransactions($object, array $xactions) {
$viewer = $this->getViewer();
- $this->rawTransactions = $xactions;
+ $this->rawTransactions = $this->cloneTransactions($xactions);
$is_parent = $object->isParentEvent();
$is_child = $object->isChildEvent();
@@ -304,6 +304,30 @@
$must_fork = ($is_child && $is_future) ||
($is_parent && !$is_future);
+ if ($is_parent && !$is_future) {
+ // We don't necessarily need to fork if whatever we're editing is not
+ // inherited by children. For example, we can add a comment to the parent
+ // event without needing to fork. Test all the stuff we're doing and see
+ // if anything is actually inherited.
+
+ $inherited_edit = false;
+ foreach ($xactions as $xaction) {
+ $modular_type = $xaction->getTransactionImplementation();
+ if ($modular_type instanceof PhabricatorCalendarEventTransactionType) {
+ $inherited_edit = $modular_type->isInheritedEdit();
+ if ($inherited_edit) {
+ break;
+ }
+ }
+ }
+
+ // Nothing the user is trying to do requires us to fork, so we can just
+ // apply the changes normally.
+ if (!$inherited_edit) {
+ $must_fork = false;
+ }
+ }
+
if ($must_fork) {
$fork_target = $object->loadForkTarget($viewer);
if ($fork_target) {
@@ -340,7 +364,7 @@
}
foreach ($targets as $target) {
- $apply = clone $this->rawTransactions;
+ $apply = $this->cloneTransactions($this->rawTransactions);
$this->applyTransactions($target, $apply);
}
}
@@ -366,4 +390,12 @@
}
}
+ private function cloneTransactions(array $xactions) {
+ $result = array();
+ foreach ($xactions as $xaction) {
+ $result[] = clone $xaction;
+ }
+ return $result;
+ }
+
}
diff --git a/src/applications/calendar/xaction/PhabricatorCalendarEventReplyTransaction.php b/src/applications/calendar/xaction/PhabricatorCalendarEventReplyTransaction.php
--- a/src/applications/calendar/xaction/PhabricatorCalendarEventReplyTransaction.php
+++ b/src/applications/calendar/xaction/PhabricatorCalendarEventReplyTransaction.php
@@ -8,6 +8,10 @@
return $object->getUserInviteStatus($actor_phid);
}
+ public function isInheritedEdit() {
+ return false;
+ }
+
public function applyExternalEffects($object, $value) {
$acting_phid = $this->getActingAsPHID();
diff --git a/src/applications/calendar/xaction/PhabricatorCalendarEventTransactionType.php b/src/applications/calendar/xaction/PhabricatorCalendarEventTransactionType.php
--- a/src/applications/calendar/xaction/PhabricatorCalendarEventTransactionType.php
+++ b/src/applications/calendar/xaction/PhabricatorCalendarEventTransactionType.php
@@ -1,4 +1,10 @@
<?php
abstract class PhabricatorCalendarEventTransactionType
- extends PhabricatorModularTransactionType {}
+ extends PhabricatorModularTransactionType {
+
+ public function isInheritedEdit() {
+ return true;
+ }
+
+}
diff --git a/src/applications/transactions/editengine/PhabricatorEditEngine.php b/src/applications/transactions/editengine/PhabricatorEditEngine.php
--- a/src/applications/transactions/editengine/PhabricatorEditEngine.php
+++ b/src/applications/transactions/editengine/PhabricatorEditEngine.php
@@ -780,7 +780,7 @@
$controller = $this->getController();
$request = $controller->getRequest();
- $action = $request->getURIData('editAction');
+ $action = $this->getEditAction();
$capabilities = array();
$use_default = false;
@@ -2098,6 +2098,17 @@
PhabricatorPolicyCapability::CAN_EDIT);
}
+ public function isCommentAction() {
+ return ($this->getEditAction() == 'comment');
+ }
+
+ public function getEditAction() {
+ $controller = $this->getController();
+ $request = $controller->getRequest();
+ return $request->getURIData('editAction');
+ }
+
+
/* -( Form Pages )--------------------------------------------------------- */

File Metadata

Mime Type
text/plain
Expires
Sun, Mar 23, 12:42 PM (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7387511
Default Alt Text
D16795.id40447.diff (5 KB)

Event Timeline