Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ics import: duplicate UIDs #799

Open
andreheuer opened this issue Mar 21, 2024 · 6 comments
Open

ics import: duplicate UIDs #799

andreheuer opened this issue Mar 21, 2024 · 6 comments

Comments

@andreheuer
Copy link

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?

@okmiim
Copy link
Collaborator

okmiim commented Mar 23, 2024

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).

@lochmueller
Copy link
Owner

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

@andreheuer
Copy link
Author

andreheuer commented Mar 25, 2024

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!

@lochmueller
Copy link
Owner

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

@okmiim
Copy link
Collaborator

okmiim commented Mar 26, 2024

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.

@ftrojahn
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants