Open mikejpeters opened 2 years ago
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.
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:
In code, access the event, call
getOccurrences()
, and then try to use the behavior: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:
https://github.com/solspace/craft-calendar/blob/ba95ac7f99a43bcdc1d43358c5b5f5ac1148c3ff/packages/plugin/src/Elements/Event.php#L292-L294