Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Feeds mapping to entity label is broken if candidate items from multiple bundles exists, for it will always select from the ...
Comment | File | Size | Author |
---|---|---|---|
#6 | entityreference-feeds-mapping-2555165-6.patch | 608 bytes | rolfmeijer |
|
Comments
Comment #2
Eric_A CreditAttribution: Eric_A commentedComment #3
Eric_A CreditAttribution: Eric_A commentedWait a minute, there's more...
Comment #4
Eric_A CreditAttribution: Eric_A commentedThe selection needs filtering on bundle.
Comment #5
Eric_A CreditAttribution: Eric_A commentedSorry, that change was mistaken. Back to needs review.
Comment #6
rolfmeijer CreditAttribution: rolfmeijer at Dutch Open Projects 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 CreditAttribution: 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 CreditAttribution: Eric_A commentedComment #9
Eric_A CreditAttribution: 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 CreditAttribution: 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.