After updating from Views 3.18 > 3.20 we noticed duplicate entries on some the previously working views.

[EDIT new finding]
I found that the issue is the taxonomy relationship (see image)

This was not causing duplicates prior to this update.

Perhaps it's the same issue as https://www.drupal.org/project/views/issues/2929804?

The only difference in query seems to be the Group By described below.

[Group by difference - old diagnosis] (I first thought this was the issue, but it seems to be related to taxonomy relationship, see above)

I noticed the difference in query was that many more fields were being added to 'Group By' on 3.20.

We have a custom code that adds nid field and a group by using query alter:

/**
 * Implements hook_views_query_alter().
 */
function hook_views_query_alter(&$view, &$query) {

  // On what views should we group by nid?
  $group_by_views = array(
    'college_program_listing',
  );

  // Add group by nid to the views
  if (in_array($view->name, $group_by_views)) {
    $query->add_field('node', 'nid', '', array('function' => 'group_by'));
    $query->add_groupby('node.nid');
  }
}

Result

Old query with 3.18 + this code:
GROUP BY node.nid, nid

Now with 3.20 + same code:
GROUP BY node.nid, nid, taxonomy_term_data_node.name, node.title, field_data_field_program_polaris_id.field_program_polaris_id_value

I'm assuming this is what's causing the duplicates. [Not anymore seems to be the taxonomy relationship described above]

Thanks!
Sia

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Siavash created an issue. See original summary.

Siavash’s picture

Issue summary: View changes
FileSize
442.66 KB
Siavash’s picture

Issue summary: View changes
nagy.balint’s picture

I have the same issue.

before:
GROUP BY uid, field_data_profile_firstname_user_entity_type, field_data_profile_lastname_user_entity_type, field_data_og_user_node_user_entity_type

after:
GROUP BY uid, users.uid, field_data_profile_firstname_user_entity_type, field_data_profile_firstname.profile_firstname_value, field_data_profile_lastname_user_entity_type, og_membership.created, field_data_og_user_node_user_entity_type, users.name

nagy.balint’s picture

nagy.balint’s picture

nagy.balint’s picture

Here is a workaround that only adds the fix from the previous issue for pgsql, while keeping the old behavior elsewhere, and so keeping backward compatibility for mysql.

This is just a quick workaround, likely a better fix can be made.

chrisgross’s picture

Priority: Normal » Critical

I am seeing this problem, as well, only as early as 3.19. This happens even if I turn off all grouping, aggregation and exposed filters. All I did was add a criteria to sort my nodes by taxonomy term weight, and I started getting duplicates where I did not have them on 3.18. I think this issue is actually critical because it has probably broken a huge number of views. #7 does fix this for me.

maticb’s picture

I can also confirm that #7 fixes the issue for me.

maticb’s picture

Status: Active » Needs review
jonnyeom’s picture

Status: Needs review » Reviewed & tested by the community

The patch fixes the issue for me as well.
Thanks!

DamienMcKenna’s picture

Status: Reviewed & tested by the community » Fixed
Parent issue: » #2960871: Plan for Views 7.x-3.23 release

Committed. Thanks.

Status: Fixed » Closed (fixed)

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

nagy.balint’s picture

Hi!

Can you point me to the commit related to this task? As its not in the task, and cant find it among the commits either.

Thanks!

DamienMcKenna’s picture

Version: 7.x-3.20 » 7.x-3.x-dev

You are correct, I made a mistake somewhere and the change didn't actually get committed. It has been committed now.