The action processor triggers an error on orphaned nodes when dealing with translated content

Created on 7 April 2023, about 1 year ago
Updated 6 March 2024, 4 months ago

Problem/Motivation

When executing a views bulk operations action (e.g.: Generate csv from selected view results) on a multilingual application. An error can occur if the node no longer exists, while still having data in the table node_field_data. The action tries to load the entity, which doesn't exist, and thus triggers an error.

Message Error: Call to a member function language() on null in Drupal\views_bulk_operations\Service\ViewsBulkOperationsActionProcessor->getPageList() (line 267 of /var/www/html/web/modules/contrib/views_bulk_operations/src/Service/ViewsBulkOperationsActionProcessor.php)

Steps to reproduce

Create one or more additional languages in the Drupal installation.
Make a node translatable.
Create one or more nodes in the default language with the status set to published.
Translate the created nodes into one or more languages.
Delete the row entry in the 'node' table with the id of one of the created nodes.
Add a views bulk operation field to the content view and include the action "Generate csv from selected view results". Save the view.
In the content overview, select all items in a non-default language and perform the "Generate csv from selected view results" action.

Proposed resolution

Initial thoughts:
In the \Drupal\views_bulk_operations\Service\ViewsBulkOperationsActionProcessor::getPageList method, include an additional check on the entity to see if it is not null before continuing to process the action.

Remaining tasks

User interface changes

none

API changes

none

Data model changes

none

πŸ› Bug report
Status

Needs review

Version

4.1

Component

Core

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024