Syncing a ManyManyList
Sometimes you want to update a ManyMany relation to have exact this set of foreign keys. Not just adding and deleting, but both - best in just one call. But ManyManyList itself doesn't come with this functionality out of the box. Really?
Traversing all parent classes of ManyManyList we can see it's a subclass of DataList, which comes with setByIDList(array $idList) which can do the job for us.
will add all needed items and remove all items from the relation table that are not in the list of IDs.
As DataList doesn't know anything about $manymany_extra_fields it cannot handle them.
Thanks to marvanni for asking this topic on our slack SilverStripe community channel.