You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 or endDate properties of it's owner,
it no longer functions correctly because it's attached to a cloned occurrence where these properties have been modified.
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 owner
Expected behavior
Calling getOccurrences() should not interfere with custom behaviors.
Craft & Plugin Info (please complete the following information):
Craft Version: 3.7.44
Calendar Version: 3.3.12
Calendar Edition: Pro
Fresh Install or Upgrade:
Additional context
The code that re-attaches the behaviors can be found here:
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:
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
The text was updated successfully, but these errors were encountered: