calendarize icon indicating copy to clipboard operation
calendarize copied to clipboard

ics import: duplicate UIDs

Open andreheuer opened this issue 11 months ago • 6 comments

I am using the import functionality to import an ICS file from Google Calendar. Now, I was wondering why not all events are being imported, so I debugged into the import function. As per my understanding, the update-function uses the UID of the VEVENT as primary key to identify the event to be updated. However, the UID in the ics file does not have to be unique, but can reference other VEVENTs. As a result, by iterating over the events to be updated (or imported), the same event in Typo3 will be updated even though the VEVENT is in fact a different one.

To test this, I have amended ImportSingleIcalEventListener.php to validate as follows:

        if (null !== $eventObj->getUid() && (int)$eventObj->getUid() > 0) {
            $this->eventRepository->update($eventObj);
            echo("update\n");
        } else {
            $this->eventRepository->add($eventObj);
            echo("added\n");
        }

then deleted all events and triggered the import:

Send ImportSingleIcalEvent for each event
-----------------------------------------

 845/845 [â–“â–“â–“â–“â–“â–“â–“â–“â–“â–“â–“â–“â–“â–“â–“â–“â–“â–“â–“â–“â–“â–“â–“â–“â–“â–“â–“â–“] 100%

 Dispatched 10 Events
 Skipped 835 Events

Run Reindex process after import
--------------------------------

Ãœbung A
added
Ãœbung B
update
Ãœbung C
update
Ãœbung D
added
Ãœbung E
update
Ãœbung F
added
Ãœbung G
added
Ãœbung H
added
Ãœbung I
added
Ãœbung J
added

As you can see, Ãœbung C and Ãœbung E was updated and not added (as it should be).

Is there any idea how to fix this?

andreheuer avatar Mar 21 '24 21:03 andreheuer

Hi @andreheuer,

could you provide us with a snippet of the ics file (especially Ãœbung A to E)?

Per specification the UID is a unique identifier for independent events.

In your case I suspect you have a repeating event (e.g. weekly) and modified the subsequent events (e.g. change the title). In such cases the UID is the same, but each VEVENT has an additional attribute RECURRENCE-ID. This however, is currently not supported (see similar issue #774).

For the case these are repeating events, the simplest fix is to recreate the events (B, C, E) in the source (Google Calendar).

okmiim avatar Mar 23 '24 18:03 okmiim

Hey @andreheuer ,

please also add, if you are using composer mode?! Non-composer installation use https://github.com/lochmueller/calendarize/blob/master/Classes/Ical/DissectEventAdapter.php and composer based use this one: https://github.com/lochmueller/calendarize/blob/master/Classes/Ical/VObjectEventAdapter.php

The first one (ICalDissect) is very old and I suggest using composer and a more modern ICS perser like the second one.

Regards, Tim

lochmueller avatar Mar 24 '24 18:03 lochmueller

Hi @okmiim,

In your case I suspect you have a repeating event (e.g. weekly) and modified the subsequent events (e.g. change the title). In such cases the UID is the same, but each VEVENT has an additional attribute RECURRENCE-ID. This however, is currently not supported (see similar issue #774).

This is exactly the case. Thank you. So looks like, the only solution is to recreate the events (which are in fact a lot) :-(

@lochmueller

please also add, if you are using composer mode?!

I am using a composer mode installation.

Thank you both!

andreheuer avatar Mar 25 '24 21:03 andreheuer

Hey @andreheuer , do you try to change the internal ID of the Import process in https://github.com/lochmueller/calendarize/blob/master/Classes/Ical/VObjectEventAdapter.php#L47 with something like this (then the event ID is the regular ID incl. the RECURRENCE-ID):

    public function getUid(): string
    {
        $recValue = $this->event->{'RECURRENCE-ID'}->getValue();
        $id = $this->event->UID->getValue();
        if(!empty($recValue)) {
            $id .= $recValue;
        }
        return $id;
    }

Regards, Tim

lochmueller avatar Mar 26 '24 11:03 lochmueller

Note to @lochmueller idea: as a side-effect it causes duplicate events. One recurrent event from the base event withRRULE and one modified with the RECURRENCE-ID.

okmiim avatar Mar 26 '24 16:03 okmiim

Working on #774 I stumbled upon EXDATE entries, too, which are not considered IMHO.

ftrojahn avatar Mar 28 '24 13:03 ftrojahn