Problem/Motivation

Something in between 4.2.5 and 4.2.6 is causing the checkboxes in my `commerce_product_variation` view to go missing. There is no ability to select each row, but there are options at the bottom of the view to select all rows. Reverting to 4.2.5 fixes the issue.

I'm investigating which commit causes the issue for me and to confirm it it's not a project specific bug, but wanted to get the issue open in case others are experiencing this.

Steps to reproduce

Create a view with VBO view (mine was commerce_product_variation)

Get checkboxes...

Add a Views Data Export display and attach it to the VBO parent view in the "Path settings" for the export display

No checkboxes...

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

andyg5000 created an issue. See original summary.

andyg5000’s picture

andyg5000’s picture

In my instance $this->view->result in https://git.drupalcode.org/project/views_bulk_operations/-/blob/4.2.x/sr... is null unless I add $this->view->execute(); right before it.

Not sure if that's the best solution, but will work up a patch once I have something to share.

andyg5000’s picture

It looks like attaching a Views Data Export display to the same view as the VBO is causing this. Not sure which module should be responsible for fixing it, but it seems like it's probably VBO's responsibility. Here's what's happening:

Somewhere between `ViewsBulkOperationsBulkForm` and `ViewsBulkOperationsViewData` the object expected as $this->view is losing it's reference to being the same object.

ViewsBulkOperationsBulkForm calls :

<?php 
    $action_options = $this->getBulkOptions();
    if (!empty($this->view->result) && !empty($action_options)) {

      // Get bulk form keys and entity labels for all rows.
      $entity_data = $this->viewData->getViewEntityData();
...

And in `ViewsBulkOperationsViewData`, the $this->view->result is null event though checked !empty above

$base_field = $this->view->storage->get('base_field');
    foreach ($this->view->result as $row_index => $row) {

If I remove the data export as an attachment to the VBO view, the issue goes away.

andyg5000’s picture

Title: Missing checkboxes in 4.2.6 » Missing checkboxes in 4.2.6 when using Views Data Export
Issue summary: View changes
andyg5000’s picture

Status: Active » Needs review

I was able to fix this by aborting the init when the view display is a data export. It seems like you wouldn't ever have VBO as part of a data export anyway. I'm not sure this is the best approach, but it does fix this issue and I can still export the data.

If you didn't want to go this route, I believe you will need to split $this->viewData into an array of views data instances based on the view display. Or maybe even not use the service container for that since it's the same object that's reused across multiple views displays being loaded in a single request.

graber’s picture

Status: Needs review » Needs work

Unfortunately we cannot accommodate every module that breaks VBO like this, we need a generic solution if it exists.
Setting this to “needs work” for now, maybe the diff will be useful for someone that needs this fixed urgently.

Thanks!

vmarchuk’s picture

I can also confirm that this issue appears in 4.2.6, but I don't see it in 4.2.5.
The fix from MR fixes this, not sure if this fix is ​"good" but can be used as a temporary solution.

sadikyalcin’s picture

Removing the VBO field from the data export view fixes the issue.

graber’s picture

Maybe you can consider using https://www.drupal.org/project/vbo_export on the view instead?

vaish’s picture

I run into this issue after the upgrade to 4.2.6. Solution suggested in comment #10 worked for me. VBO field doesn't serve any purpose in the "data export" display.

vmarchuk’s picture

I can also confirm that the solution suggested in comment #10 helped solve this problem!