Duplicate row results for some data types

Created on 20 March 2019, almost 6 years ago
Updated 28 August 2024, 4 months ago

Problem/Motivation

Certain data types (like composite fields) result in multiple rows when placed into a View. As an example, from #3041878-26: Duplicate row results for some data types β†’ :

a custom composite element with 5 fields leads to 5 rows if included in a view

Proposed resolution

Scale webform_views to show singular instances of multi-field elements like composite fields.

Remaining tasks

Original report

Problem

When adding a Text Format element type to a form, the submission results are duplicated. This appears to be specific to this element type and perhaps others. Additionally, the duplicate results only happen when data is added to the field, not when left empty.

Note: This bug does not exist in 5.0.0-alpha6

Reproduce

  1. Create a webform and submissions with the Text Format element type in the form
  2. Create a view for Webform Submission data
  3. Add field with Text Format element type
πŸ› Bug report
Status

Needs work

Version

5.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States brandonratz

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • I'm using a workaround as well.

    Your code's performance can be improved. Instead of using in_array inside the for loop, use a keyed array. In addition, there can be more than one sid field, so it might not be named that. In addition, you should update the row count.

          $combined = [];
          foreach ($view->result as $row) {
            /** @var \Drupal\webform\WebformSubmissionInterface $webform_submission */
            $webform_submission = $row->_entity;
            if (!isset($combined[$webform_submission->id()])) {
              $combined[$webform_submission->id()] = $row;
            }
          }
    
          // Replace the result set with the combined result.
          $view->result = $combined;
          $view->total_rows = count($combined);
    
  • Hi @solideogloria, not sure why but your approach broke any views pages that used anything other than the 'Table' format, and broke the "Webform submission operations bulk form" checkboxes (they no longer appeared). I am not sure why (and don't currently have time to test) but I have reverted to my original approach and it continues to work.

  • First commit to issue fork.
  • Merge request !29Reroll patch from #26 β†’ (Open) created by prudloff
  • Pipeline finished with Failed
    4 months ago
    Total: 153s
    #267023
Production build 0.71.5 2024