Skip to content
This repository has been archived by the owner. It is now read-only.

Fix _id sync #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tenKinetic
Copy link

@tenKinetic tenKinetic commented May 4, 2019

I had an issue with the synchronisation of _ids in collection links.
Some were not updated and it seems it was a dangling reference in a for loop since it was consistently the same ones every time.
This update fixes the dangling reference so the new _ids taken from the $idsMapping array are always applied without being lost in subsequent loops.

Not sure if this is related to #3 since that seems to be more about them not restoring at all. However, I do not have that problem with the code as it is. My PR only fixes the dangler and it also leaves the save until even later than your suggested alternative to that PR and does it after the nested loops are all completed and so sends the full $entries array just once.

EDIT:

I've made a further change to allow for both single item and multiple item collection links. Now I think I know what #3 was about. That user obviously had all their collection links set to multiple:false. With the code as it was, none would have been processed. The proposed change might have reversed the issue and processed all the single item collection links and none of the multiple item collection links. This update will process both.

tenKinetic added 2 commits May 4, 2019 11:16
Remove dangling reference to $entry which results in some _ids not
being updated;
Send all the entries over once after syncing the _ids
If the collection link variable is an array the existing code is fine
but when the collection link is created with multiple:false it’s not an
array but an object on which we set the _id directly.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant