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.

CommentFileSizeAuthor
#8 2750453.patch631 bytesmeb
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

e5sego created an issue. See original summary.

egontinno’s picture

Also 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.

mloyat’s picture

Same issue here, since the module update.
For a simple query with contextual filter and relationship with a fieldcollection.

dcine’s picture

Same issue here, and since the module update too. I need to use the "Delta 1"
Any solution (please!)?

e5sego’s picture

Workaround: 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.

dcine’s picture

Ok, but i need too use delta 2, 3, and more… Any solution (please!)?

sdudnik’s picture

Same issue. After updating to 3.14 views incorrectly show same events twice or more (in month calendar)

meb’s picture

As 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.

meb’s picture

Status: Active » Needs review
dcine’s picture

I 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)?

meb’s picture

dcine, 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?

e5sego’s picture

I can confirm the patch in #8 is working. Thank's, meb.

Anonymous’s picture

Status: Needs review » Reviewed & tested by the community

The 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.

dcine’s picture

Status: Reviewed & tested by the community » Needs review

Yes, 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)?

dcine’s picture

Thanks! 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.

Anonymous’s picture

Just to clarify dcine; is the patch working for you or is it not? Your latest two comments somewhat read like they contradict each other.

hass’s picture

Priority: Normal » Critical
Status: Needs review » Reviewed & tested by the community

Closed #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!

hass’s picture

This is the case that introduced this bug and it looks like it may get rolled back.

dcine’s picture

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

andrewfn’s picture

The 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.

hass’s picture

@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.

dboulet’s picture

I 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.

jaydub’s picture

Just a note that this issue affects that patch to the entityreference module in this issue: #1468862: Add a delta filter in the Views relationships

osopolar’s picture

Patch worked for me too using delta 1 to limit view-relations with field collection items.

jacov’s picture

+1 confirmed this is an issue. attempting patch.

dani3lr0se’s picture

Ran into this same issue today while using delta 1. Tried the patch in #8 and it worked great. Thanks @meb :)

Sam152’s picture

My issue was completely different to those described, but #8 makes my tests green. +1

DamienMcKenna’s picture

Version: 7.x-3.14 » 7.x-3.x-dev
Parent issue: » #2505379: Plan for Views 7.x-3.15 release

Lets mark this to be included in the next release.

dani3lr0se’s picture

Thanks @DamienMcKenna

abarpetia’s picture

@DamienMcKenna Thanks for including this in next release.

massiws’s picture

I 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.

riddhi.addweb’s picture

Issue tags: +views, +Field collection
DamienMcKenna’s picture

Issue tags: -views

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 8: 2750453.patch, failed testing.

abarpetia’s picture

I 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.

MyriamB’s picture

Annoying 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

joelpittet’s picture

Status: Needs work » Closed (duplicate)
francismak’s picture

Thx @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.

osopolar’s picture

bellagio’s picture

Editing 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.