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 -
Issue fork views_bulk_operations-3585349
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
Comment #2
mariacha1 commentedComment #4
mariacha1 commentedComment #6
graber commentedThanks, I simplified greatly though. Groups are strings by views sql query class method doc comment.
Comment #8
mariacha1 commentedOoo, love it. Thanks!