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.
After upgrading to views 7.x-3.14 I found nodes referencing multiple images (images are stored in a field collection) are creating multiple results of same node. The relation to field collection has setting delta=1, which seems not handled correctly. The query is generated without any delta statement.
Switching to delta=2 or greater, the query contains the delta and results are as expected.
Note: the mentioned view/query is quite complex and uses distinct already. It might be the above problem will just happen under seldom circumstances.
Comment | File | Size | Author |
---|---|---|---|
#8 | 2750453.patch | 631 bytes | meb |
Comments
Comment #2
egontinno CreditAttribution: egontinno commentedAlso have the same problem. Very simple gallery query (no distinct), but all picture are now displayed. Changing to delta 2 make it work for now. Thanks for hint.
Comment #3
mloyat CreditAttribution: mloyat commentedSame issue here, since the module update.
For a simple query with contextual filter and relationship with a fieldcollection.
Comment #4
dcine CreditAttribution: dcine as a volunteer commentedSame issue here, and since the module update too. I need to use the "Delta 1"
Any solution (please!)?
Comment #5
e5sego CreditAttribution: e5sego commentedWorkaround: use a filter criteria to the delta value of field (field_name:delta).
Note: this will only return items having the related data, like you would check "relation is required" in the relation settings.
Comment #6
dcine CreditAttribution: dcine as a volunteer commentedOk, but i need too use delta 2, 3, and more… Any solution (please!)?
Comment #7
sdudnik CreditAttribution: sdudnik commentedSame issue. After updating to 3.14 views incorrectly show same events twice or more (in month calendar)
Comment #8
meb CreditAttribution: meb commentedAs a temporary stop-gap I configured a filter criteria as suggested in post #5, and it worked for me.
This issue relates to the following line in the build_join on line 1591 of views\includes\handers.inc:
elseif (!empty($info['value'])) {
When selecting a delta of "1", the option value is zero indexed so it's actually "0". empty("0") returns false, so as a result the join from field_collection is not included in the query.
Suggestion to handle joining to a value of "0", FALSE, and other similar values that may be stored in a table:
elseif (isset($info['value'])) {
I tested this on several sites which generate views based on "Delta 1" and it worked for me even after removing the fix suggested in post #5. Attempted to provide a patch.
Comment #9
meb CreditAttribution: meb commentedComment #10
dcine CreditAttribution: dcine as a volunteer commentedI tried the patch and ... nothing happens. In my case, well, I can not use a filter because I need to use several deltas (1, 2, 3 ...)
Any help (please)?
Comment #11
meb CreditAttribution: meb commenteddcine, you are using a view with a relationship from a node base table to a field collection? And under "Configure relationship", you are selecting "1" under Delta, where it says:
"The delta allows you to select which item in a multiple value field to key the relationship off of. Select "1" to use the first item, "2" for the second item, and so on. If you select "All", each item in the field will create a new row, which may appear to cause duplicates."
The patch should fix the issue when using a delta of 1. How are you using several deltas? Are you configuring multiple relationships for a single view?
Comment #12
e5sego CreditAttribution: e5sego commentedI can confirm the patch in #8 is working. Thank's, meb.
Comment #13
Anonymous (not verified) CreditAttribution: Anonymous at Ashday Interactive Systems commentedThe patch in #8 fixes the issue for me. I had a view (with a number of filters and contextual filters), and one of the contextual filters had a delta of 1 set up; after updating Views, it was ignoring the delta, but with the patch it works as originally built and intended.
Comment #14
dcine CreditAttribution: dcine as a volunteer commentedYes, I add several relationships in a view. The view is to show list of images. The field image is a multivalue field, and for show all the images i use diferent "deltas" (1, 2, 3, until 10).
I added the patch and nothing happens.
Any help (please)?
Comment #15
dcine CreditAttribution: dcine as a volunteer commentedThanks! I added again the patch and… yes, fixes the issue (for me). One thing, i have'nt added the filter,I only updated the view.
Comment #16
Anonymous (not verified) CreditAttribution: Anonymous at Ashday Interactive Systems commentedJust to clarify dcine; is the patch working for you or is it not? Your latest two comments somewhat read like they contradict each other.
Comment #17
hass CreditAttribution: hass commentedClosed #2751747: All JOINs corrupted / missing conditions in v3.14 - no results after testing and this patch fixes the issue. We should create a new release ASAP!
Comment #18
hass CreditAttribution: hass commentedThis is the case that introduced this bug and it looks like it may get rolled back.
Comment #19
dcine CreditAttribution: dcine as a volunteer commentedSorry for my lack of definition (and the delay in answering), but yes, the patch is working for my instalallation. Install it several times and at first did not work, but then remove the filters and finally worked. Thanks!
Comment #20
andrewfn CreditAttribution: andrewfn as a volunteer commentedThe views 7.x-3.14 security update broke the public website of a major client. As a strong supporter of Drupal is it really embarrassing for me to have to tell clients not to use the current version of views, but to go with 3.13 which has a security vulnerability. I think it's important for the reputation of Drupal to get this patch committed ASAP.
Comment #21
hass CreditAttribution: hass commented@andrewfn: I see it like you, but what you may do - is installing 3.14 with the #1090432: Allow additional field-to-field conditions with the default views_join handler Rollback applied. That may work, too. From comment #19 I'm not sure if this patch here really solves all issues.
Comment #22
dboulet CreditAttribution: dboulet commentedI ran into this same issue with views which use sorting provided by the DraggableViews module. The extra conditions for the joins, which check for delta = 0, disappeared after the last upgrade to Views. The patch in #8 fixes the issue. I agree with hass, a new release should be created.
Comment #23
jaydub CreditAttribution: jaydub commentedJust a note that this issue affects that patch to the entityreference module in this issue: #1468862: Add a delta filter in the Views relationships
Comment #24
osopolarPatch worked for me too using delta 1 to limit view-relations with field collection items.
Comment #25
jacov CreditAttribution: jacov as a volunteer commented+1 confirmed this is an issue. attempting patch.
Comment #26
dani3lr0se CreditAttribution: dani3lr0se as a volunteer commentedRan into this same issue today while using delta 1. Tried the patch in #8 and it worked great. Thanks @meb :)
Comment #27
Sam152 CreditAttribution: Sam152 at PreviousNext commentedMy issue was completely different to those described, but #8 makes my tests green. +1
Comment #28
DamienMcKennaLets mark this to be included in the next release.
Comment #29
dani3lr0se CreditAttribution: dani3lr0se as a volunteer commentedThanks @DamienMcKenna
Comment #30
abarpetia CreditAttribution: abarpetia as a volunteer commented@DamienMcKenna Thanks for including this in next release.
Comment #31
massiws CreditAttribution: massiws commentedI have many views with a relationship with Field collection.
In some cases the patch #8 fix the issues, but for other views I have to adopt workaround suggested in #5.
I'll try to debug deeper as soon as possible.
Comment #32
riddhi.addweb CreditAttribution: riddhi.addweb commentedComment #33
DamienMcKennaComment #35
abarpetia CreditAttribution: abarpetia as a volunteer commentedI have just checked 7.x-3.x-dev branch and can confirm that #8 code is already applied over there. That's why attached patch is failing to test.
I recommend closing this request.
Comment #36
MyriamB CreditAttribution: MyriamB commentedAnnoying effect of this version.
Comment #5 worked for me:
Relation delta set to all, then in the new field filter delta available, I set it equal to 0.
Thank you
Comment #37
joelpittetI think this may have been committed in #2754667: "In none of" (= Off/0) filter operator stopped working after Views update to 7.x-3.14
Comment #38
francismak CreditAttribution: francismak commentedThx @MyriamB in #36
You solutions work and we don't have to apply any patch at all.
For the others, as said, in Relations, set Delta to 'All', then a new filter criteria, search for Delta, add it and set Equal to zero.
Comment #39
osopolarConfirming #37, it's the same fix as in #2754667: "In none of" (= Off/0) filter operator stopped working after Views update to 7.x-3.14 .
Comment #40
bellagio CreditAttribution: bellagio commentedEditing my comments because i am not sure what caused or got rid of the duplicates in the first place. Ended up using views-7.x-3.17.