1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-17 20:32:41 +01:00

Record a "series parent PHID" on Calendar events that retains relationships after forks

Summary:
When you edit "X and all future events", X becomes the new parent of an event series.

Currently, it loses its relationship to its original parent. Instead, retain that relationship -- it's separate from the normal "parent", but we can use it to make the UI more clear or tweak behaviors later.

This mostly just keeps us from losing/destroying data that we might need/want later.

Test Plan:
  - Ran migrations.
  - Cancelled "X and all future events", saw sensible-appearing beahvior in the database for "seriesParentPHID".

Reviewers: chad

Reviewed By: chad

Differential Revision: https://secure.phabricator.com/D16780
This commit is contained in:
epriestley 2016-10-31 13:47:45 -07:00
parent f44a9a4e48
commit b084efb362
3 changed files with 23 additions and 0 deletions

View file

@ -0,0 +1,5 @@
ALTER TABLE {$NAMESPACE}_calendar.calendar_event
ADD seriesParentPHID VARBINARY(64);
UPDATE {$NAMESPACE}_calendar.calendar_event
SET seriesParentPHID = instanceOfEventPHID;

View file

@ -84,6 +84,13 @@ final class PhabricatorCalendarEventCancelController
// NOTE: If you can't edit some of the future events, we just // NOTE: If you can't edit some of the future events, we just
// don't try to update them. This seems like it's probably what // don't try to update them. This seems like it's probably what
// users are likely to expect. // users are likely to expect.
// NOTE: This only affects events that are currently in the same
// series, not all events that were ever in the original series.
// We could use series PHIDs instead of parent PHIDs to affect more
// events if this turns out to be counterintuitive. Other
// applications differ in their behavior.
$future = id(new PhabricatorCalendarEventQuery()) $future = id(new PhabricatorCalendarEventQuery())
->setViewer($viewer) ->setViewer($viewer)
->withParentEventPHIDs(array($event->getPHID())) ->withParentEventPHIDs(array($event->getPHID()))

View file

@ -27,6 +27,7 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
protected $isRecurring = 0; protected $isRecurring = 0;
protected $seriesParentPHID;
protected $instanceOfEventPHID; protected $instanceOfEventPHID;
protected $sequenceIndex; protected $sequenceIndex;
@ -140,10 +141,16 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
'a recurring parent event!')); 'a recurring parent event!'));
} }
$series_phid = $this->getSeriesParentPHID();
if (!$series_phid) {
$series_phid = $this->getPHID();
}
$child = id(new self()) $child = id(new self())
->setIsCancelled(0) ->setIsCancelled(0)
->setIsStub(0) ->setIsStub(0)
->setInstanceOfEventPHID($this->getPHID()) ->setInstanceOfEventPHID($this->getPHID())
->setSeriesParentPHID($series_phid)
->setSequenceIndex($sequence) ->setSequenceIndex($sequence)
->setIsRecurring(true) ->setIsRecurring(true)
->attachParentEvent($this) ->attachParentEvent($this)
@ -401,6 +408,7 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
'icon' => 'text32', 'icon' => 'text32',
'mailKey' => 'bytes20', 'mailKey' => 'bytes20',
'isRecurring' => 'bool', 'isRecurring' => 'bool',
'seriesParentPHID' => 'phid?',
'instanceOfEventPHID' => 'phid?', 'instanceOfEventPHID' => 'phid?',
'sequenceIndex' => 'uint32?', 'sequenceIndex' => 'uint32?',
'isStub' => 'bool', 'isStub' => 'bool',
@ -435,6 +443,9 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
'columns' => array('instanceOfEventPHID', 'utcInstanceEpoch'), 'columns' => array('instanceOfEventPHID', 'utcInstanceEpoch'),
'unique' => true, 'unique' => true,
), ),
'key_series' => array(
'columns' => array('seriesParentPHID', 'utcInitialEpoch'),
),
), ),
self::CONFIG_SERIALIZATION => array( self::CONFIG_SERIALIZATION => array(
'recurrenceFrequency' => self::SERIALIZATION_JSON, 'recurrenceFrequency' => self::SERIALIZATION_JSON,