How to solve move-contact-with-birthdate-between-addressbooks bug

There is a bug when moving an contact with birthdate to another address book.
I found the cause and described it in Can't swap contacts between address books · Issue #20492 · nextcloud/server · GitHub


The problem is as follows:

  1. When a vcard changes, “onCardChanged” is called on the BirthdayService, so that the birthdate can be stored in the calendar.
  2. BirthdayService::updateCalendar checks if the calendar entry already exists with CalDavBackEnd::getCalendarObject($calendarId, $objectUri). That one says “no, does not exist”, because the $objectUri is at the new calendar.
  3. BirthdayService::updateCalendar tries to create a new calendar entry with CalDavBackEnd::createCalendarObject($calendarId, $objectUri, $calendarData->serialize()). That fails, because createCalendarObject first checks if an calendar entry with that UID (not uri!) already exists, and throws an exception here.

I am not sure what the right solution would be here.
Step 2 could use the UID to check if the calendar entry exists instead of the URI, but that may have side effects I do not know of.


What do the nextcloud devs think how that should be solved?

Can we keep the dev discussion there? I don’t think the branching off of the comments on the forum will help move things forward :v:

We stay at GitHub for such discussions.