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

RKRefetchManagedObjectInContext() can return object on incorrect context #2283

Merged
merged 2 commits into from Nov 16, 2015

Conversation

pr1001
Copy link
Contributor

@pr1001 pr1001 commented Aug 27, 2015

The RKRefetchManagedObjectInContext() function takes an object in an original context and refetches it on the provided destination context. However, if the object only has a temporary ID, the same object is returned. While it is true that refetching on the destination context would fail in the absence of a permanent ID, returning the original object can lead to it being used on the wrong, destination queue.

While this function is only called inside of an RKRefetchingMappingResult, which in turn only gets created by RKManagedObjectRequestOperation after permanent IDs are obtained, I think it's dangerous to leave a potential context-crossing error in place and would be better to return nil.

@segiddins
Copy link
Member

@pr1001 could you make a PR for that?

@segiddins
Copy link
Member

This seems to have failed on CI

@pr1001
Copy link
Contributor Author

pr1001 commented Aug 31, 2015

I'll look into this again. When I was developing I got ~180 test failures. I made a separate clean checkout of development and got the same number of errors, so it seemed like my changes were not the cause.

@segiddins
Copy link
Member

Make sure you're running the test server: bundle exec rake server

pr1001 and others added 2 commits November 13, 2015 18:22
If the function is passed a temporary managed object, it will return
nil, instead of the original object not on the destination queue.
Because -[RKRefetchingMappingResult refetchedMappingResult] would create
a copy of the mapped results and overwrite their entries with the
objects in the correct context, it also needed to be updated, since nil
results wouldn't overwrite the original value.
context

Also fix incorrect changes to the mutable dictionary.
@pr1001
Copy link
Contributor Author

pr1001 commented Nov 13, 2015

Sorry about not getting to this sooner. The request should now work and pass all tests.

@segiddins
Copy link
Member

Looks ace! Will merge once CI runs

@pr1001
Copy link
Contributor Author

pr1001 commented Nov 16, 2015

Looks like it's good to good.

segiddins added a commit that referenced this pull request Nov 16, 2015
RKRefetchManagedObjectInContext() can return object on incorrect context
@segiddins segiddins merged commit fb6d3df into RestKit:development Nov 16, 2015
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

Successfully merging this pull request may close these issues.

None yet

2 participants