Problem/Motivation

This module is incompatible with views built using https://www.drupal.org/project/views_contextual_filters_or. That module allows you to declare that contextual filters be added using the "OR" condition instead of the "AND" condition. That code breaks VBO's confirmation screen, unsetting the list of items you selected.

On the code level, the module modifies the "where" sections of View Queries look like this:

  [
      0 => [
          'conditions' => [                                                                                                                                                                 
              [
                  'field_1',                                                                                                                                                  
                  ["a", "b"],                                                                                                                                                     
                  'IN',
              ],
              [
                  'field_2',                                                                                                                                                 
                  [3393, 3395, 3400],
                  'IN',                                                                                                                                                                     
              ],                                                                                                                                                                          
          ],
         'type' => 'OR',
      ],
  ];

However, VBO adds an additional where statement to the "0" group within the $this->view->query->where variable, changing the array to this:

[
      0 => [
          'conditions' => [                                                                                                                                                                 
              [
                  'field_1',                                                                                                                                                  
                  ["a", "b"],                                                                                                                                                     
                  'IN',
              ],
              [
                  'field_2',                                                                                                                                                 
                  [3393, 3395, 3400],
                  'IN',                                                                                                                                                                     
              ],     
              [
                  'base_field_alias',                                                                                                                                                 
                  [
                      'base_field_value_1', 'base_field_value_2'
                  ],
                  'IN',                                                                                                                                                                     
              ],                                                                                                                                                                          
          ],
          'type' => 'OR',
      ],
  ];

But we don't want an OR conjunction for the list of nodes chosen, we want that to be an "AND" so that only the items I've selected show.

I think it would be logically equivalent to add the "base_field_alias" as its own group at the end of the $this->view->query->where variable, instead of adding it within the "0" grouping, like this:

[
      0 => [
          'conditions' => [                                                                                                                                                                 
              [
                  'field_1',                                                                                                                                                  
                  ["a", "b"],                                                                                                                                                     
                  'IN',
              ],
              [
                  'field_2',                                                                                                                                                 
                  [3393, 3395, 3400],
                  'IN',                                                                                                                                                                     
              ],                                                                                                                                                            
          ],
          'type' => 'OR',
      ],
     1 => [
          'conditions' => [                                                                                                                                                                 
              [   
                  'base_field_alias',                                                                                                                                                 
                  [
                      'base_field_value_1', 'base_field_value_2'
                  ],
                  'IN',                                                                                                                                                                     
              ],   
          ],                
      ]
  ];

That wouldn't conflict with other modules that may also be modifying the "where" values in group 0.

Steps to reproduce

1. Create a view that allows Views Bulk Operations and that uses the views_contextual_filters_or module.
2. Under "Query settings" on the view, check the "Contextual filters OR" checkbox and add one contextual filter.
3. Use VBO to select a few entities and proceed to the confirmation page.
4. "Items selected:" on the confirmation page will be empty.

Proposed resolution

Change populateQueue's handling of the $this->view->query->where variable to put the subset of selected entities at the end of the conditions, instead of appending it to the 0 group of conditions.

Remaining tasks

Review patch

User interface changes

- none -

API changes

- none -

Data model changes

- none -

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mariacha1 created an issue. See original summary.

mariacha1’s picture

Issue summary: View changes

mariacha1’s picture

Issue summary: View changes
Status: Active » Needs review

  • ce356552 committed on 4.4.x
    #3585349: Changed group for VBO base field filter.
    
graber’s picture

Status: Needs review » Fixed

Thanks, I simplified greatly though. Groups are strings by views sql query class method doc comment.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

mariacha1’s picture

Ooo, love it. Thanks!

Status: Fixed » Closed (fixed)

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