Custom event behaviors are attached to occurrence clones #377
mikejpeters
started this conversation in
Feature Requests
Replies: 1 comment
-
Any release date related to that issue? I think this cause a major major issue : resaving a calendar resave all occurences of all events of this calendar. Causing Craft to crash because it needs to save 1700 elements for a calendar containing 70 events. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the bug or issue you're experiencing
When using a custom behavior to add functionality to the
Event
class,the behavior gets assigned to clones of the event during calls to
$event->getOcurrence()
This means that if the behavior relies on the
startDate
orendDate
properties of it's owner,it no longer functions correctly because it's attached to a cloned occurrence where these properties have been modified.
Steps to reproduce
Create a custom behavior and register it:
Create an event with multiple occurrences
In code, access the event, call
getOccurrences()
, and then try to use the behavior:The result will be the start date of the last occurrence, because calling
getOccurrences()
has the side-effect of attaching the existing behavior to the occurrence instead of it's original ownerExpected behavior
Calling
getOccurrences()
should not interfere with custom behaviors.Craft & Plugin Info (please complete the following information):
Additional context
The code that re-attaches the behaviors can be found here:
craft-calendar/packages/plugin/src/Elements/Event.php
Lines 292 to 294 in ba95ac7
Beta Was this translation helpful? Give feedback.
All reactions