Problem/Motivation

When running VBOs, I have been getting this error message:

Error: Call to a member function getOffset() on null in Drupal\views_bulk_operations\Service\ViewsBulkOperationsActionProcessor->getPageList() (line 203 of …/views_bulk_operations/src/Service/ViewsBulkOperationsActionProcessor.php).

This is the code starting at line 203:

    if ($pager_offset = $this->view->pager->getOffset()) {
      $offset += $pager_offset;
    }

This code is the only use of $this->view->pager in this class.

I changed this code to be robust against a NULL: $this->view->pager?->getOffset()

When I did that, I ran into the issue in #3217544: View query not built. Adding the fix in that issue fixed the problem for me.

Proposed resolution

Do the fix referred-to above (merge request for this issue) and the fix in #3217544: View query not built.

Remaining tasks

Implement.

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

liam morland created an issue. See original summary.

liam morland’s picture

Status: Active » Needs review

The merge request contains the protection against a null pager proposed in the issue summary.

erutan’s picture

Status: Needs review » Reviewed & tested by the community

This is a simple fix and I've been using it after having some oddness with pagers in VBO with no issues.

graber made their first commit to this issue’s fork.

graber’s picture

Status: Reviewed & tested by the community » Needs work

https://git.drupalcode.org/project/views_bulk_operations/-/jobs/8717411

 Line   src/Service/ViewsBulkOperationsActionProcessor.php                
 ------ ------------------------------------------------------------------ 
  204    Using nullsafe method call on non-nullable type                   
         Drupal\views\Plugin\views\pager\PagerPluginBase. Use -> instead.  
         🪪  nullsafe.neverNull
liam morland’s picture

This could mean the schema is wrong. It says it is non-nullable, but having it being null is exactly what was happening. I could add an ignore comment.

graber’s picture

Yes, I think that’s fine. Let’s just point to core views file in a comment above.

liam morland’s picture

Status: Needs work » Needs review

Sorry, I don't know what file to refer to. I added the ignore statement.

graber’s picture

Probably ViewExecutable.php, that’s where the pager property is?

graber’s picture

I can update when merging I guess..

graber’s picture

  • graber committed b6449760 on 4.4.x authored by liam morland
    fix: #3555811 Make ViewsBulkOperationsActionProcessor robust against...
liam morland’s picture

Status: Needs review » Fixed

Thanks. I have created a follow-up to fix the types: #3585443: Fix types in ViewExecutable.

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.

graber’s picture

Not good. Sorry for not linking earlier
https://www.drupal.org/project/drupal/issues/3585410

Status: Fixed » Closed (fixed)

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