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.

Comments

chasingmaxwell’s picture

StatusFileSize
new776 bytes
dscl’s picture

Priority: Normal » Major
Status: Active » Reviewed & tested by the community

Hey 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!

geek-merlin’s picture

Yes, codewise it's identical to mine from the dup issue, so +1 for RTBC.

amitaibu’s picture

Status: Reviewed & tested by the community » Fixed

Merged, thanks!

amitaibu’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.