Needs review
Project:
Entity reference
Version:
7.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
21 Aug 2015 at 06:42 UTC
Updated:
26 Mar 2018 at 09:17 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
eric_a commentedComment #3
eric_a commentedWait a minute, there's more...
Comment #4
eric_a commentedThe selection needs filtering on bundle.
Comment #5
eric_a commentedSorry, that change was mistaken. Back to needs review.
Comment #6
rolfmeijer commentedThe patch form comment 2 does not apply to 7.x-1.5 anymore, because the line
$options = reset($options);is already removed. I’ve made a new patch, based on 7.x-dev from 16 Aug 2017.Comment #7
eric_a commentedThanks for taking over, @rolfmeijer.
Around 1.2 the
reset($options)was moved into a conditional. If you don't kill thisreset()anymore I think the code won't find the matching entities anymore. It didn't when I made the first patch, if I remember correctly.I'd say the fix should be moved inside the conditional as well, *including* the killing of
$options = reset($options)or thereset()will now return a scalar and the next line does anarray_keys()on it to get entity IDs, and then do areset()to get the first ID.. Thatreset()line being there for a long time IMO means this code is not working correct for a long time, given that it will only select from the first bundle.Comment #8
eric_a commentedComment #9
eric_a commentedTo be honest, I'm not so sure anymore if my patch was actually changing selection behavior. Before 1.2 the patch would prevent the errors mentioned in #1943300: array_keys() and reset() notices in entityreference_feeds_set_target() during feed import if entity doesn't exist I think, but it would not actually change selecting the first entity from the list, because the first entity would be the first entity below the first bundle key created, I think. (Of course it is true that we then totally depend on what appears to be an implementation detail.) For clarity it would make sense to move the comment
// Use the first matching entity.two lines up then, but usingoptions_array_flatten()and areset()instead of two times areset()does not really change behavior I think. (Other then introducing a dependency on the options module...)Comment #10
mariusm commentedHello,
The solution does not solve all the problems.
I have label 78.
For 78 is returned :
5078 ( with id_1 )
78 ( with id_2 )
7809 ( with id_3 )
With reset ... the program returns id_1 but should return id_2 .
Thanks.