solspace / craft-calendar

Calendar for Craft: The most reliable and powerful event management plugin for Craft.
http://docs.solspace.com/craft/calendar/v5
Other
15 stars 15 forks source link

FeedMe updates all languages #287

Closed ThomasDeMarez closed 2 months ago

ThomasDeMarez commented 5 months ago

Describe the bug or issue you're experiencing

The indexBy function on EventQuery does not seem to actually return Events by the requested index.

FeedMe uses this to fetch Events on propagation to other sites. (services/Elements.php - _saveElementInternal()) This causes FeedMe to not find or use the wrong Event and propagate the Event with the wrong data to the wrong site.

Steps to reproduce

  1. Setup a multi site Craft install
  2. Create a calendar
  3. Create a translatable field
  4. Setup FeedMe a. One for the first site b. One for the second site
  5. Sync different data to the field in each of the two FeedMe feeds

Expected behavior The translated field contains the correct data according to the coupled feed.

Craft & Plugin Info (please complete the following information):

Additional context Adding the following snippet to the all() method on EventQuery just before return $this->events; fixes the issue for FeedMe.

if($this->indexBy) {
    $events = [];

    foreach($this->events as $event) {
       $events[$event->{$this->indexBy}] = $event;
    }

    return $events;
}

Lacking proper validation of course

kjmartens commented 3 months ago

Sorry for the long delay @ThomasDeMarez.

We're checking into this now. Thanks for the code fix suggestion. 🙂