When a provider supplies an array of ids, the order of those ids is not guaranteed to remain the same when output to field items. This is because the $ids variable is reassigned to the output of validateReferenceableEntities() on line 306 of entityreference_prepopulate.module. In the case of the EntityReference_SelectionHandler_Generic handler, the output is reordered by an EntityFieldQuery. If instead the $ids variable was intersected with the validated output, order would be preserved while invalid references would be removed.
I have a patch with a proposed fix which I will upload shortly.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | prevent-reordering-of-ids-2316737-1.patch | 776 bytes | chasingmaxwell |
Comments
Comment #1
chasingmaxwell commentedComment #2
dscl commentedHey there,
This issue has been around for years, huh?
I got impacted by this today, created a patch and when I came here for submitting it I've found this one which is pretty similar to mine.
Not really sure why it wasn't pushed into the code yet, but I've tested in the latest release (1.6) and it works!
So I'm RTBC'ing it to hopefully see it committed.
I'm also making it Major considering it impacts the functionality expected outcome directly.
Cheers!
Comment #3
geek-merlinYes, codewise it's identical to mine from the dup issue, so +1 for RTBC.
Comment #5
amitaibuMerged, thanks!
Comment #6
amitaibuNew release will be ready soon - https://www.drupal.org/project/entityreference_prepopulate/releases/7.x-1.7