Problem/Motivation

When using VBO on a view with relationships, you can easily end up with multiple entities with the same bundle key (e.g. 'type' is a common bundle key). If you filter the bundle of one of these entities and use a VBO action on the other, _views_bulk_operations_modify_action_get_bundles() will apply the bundle restriction of the filtered entity on the actionable entity's VBO form.

  $info = entity_get_info($entity_type);
  $bundle_key = $info['entity keys']['bundle'];
  // Check if this View has a filter on the bundle key and assemble a list
  // of allowed bundles according to the filter.
  $filtered_bundles = array();
  if (!empty($bundle_key) && isset($view->filter[$bundle_key]) && !empty($view->filter[$bundle_key]->value)) {
    $operator = $view->filter[$bundle_key]->operator;
    if ($operator == 'in') {
      $filtered_bundles = $view->filter[$bundle_key]->value;
    }
    elseif ($operator == 'not in') {
      $bundle_names = array_keys($info['bundles']);
      $filtered_bundles = array_diff($bundle_names, $view->filter[$bundle_key]->value);
    }
  }

Proposed resolution

_views_bulk_operations_modify_action_get_bundles() should check that the filter is on the same relationship (or base table) as the action before applying the filter.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

andrewbelcher’s picture

Status: Active » Needs review
FileSize
2.18 KB

Here is a patch that resolves it...

bojanz’s picture

Title: modify.action.inc doesn't check bundle key is for the same entity » modify.action.inc doesn't check bundle filter is for the same entity
Issue summary: View changes
Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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

Nitebreed’s picture

The patch in #2 doesn't collect all bundles that need to be added or removed, instead it strips out every other bundle other that the first filter that has to be 'in'

Attached (SVN) patch fixes this.

Nitebreed’s picture

Status: Closed (fixed) » Needs review

  • bojanz committed b70609b on 8.x-1.x authored by andrewbelcher
    Issue #2039909: modify.action.inc doesn't check that the bundle filter...