Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#4 | views_bulk_operations-vbo-modify.action.inc_.patch | 1.57 KB | Nitebreed |
#1 | 2039909-improve_bundle_filter_handling.patch | 2.18 KB | andrewbelcher |
Comments
Comment #1
andrewbelcher CreditAttribution: andrewbelcher commentedHere is a patch that resolves it...
Comment #2
bojanz CreditAttribution: bojanz commentedCommitted:
http://drupalcode.org/project/views_bulk_operations.git/commitdiff/b7060...
Thanks!
Comment #4
NitebreedThe 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.
Comment #5
Nitebreed