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

Created on 7 April 2023, over 1 year ago
Updated 18 September 2024, 2 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

Postponed: needs info

Version

4.2

Component

Actions

Created by

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

Comments & Activities

  • Issue created by @esdrasterrero
  • @esdrasterrero opened merge request.
  • @esdrasterrero opened merge request.
  • Status changed to Needs review over 1 year ago
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.0.7 + Environment: PHP 7.3 & MySQL 5.7
    last update over 1 year ago
    Composer error. Unable to continue.
  • πŸ‡³πŸ‡±Netherlands falco010 πŸ‡³πŸ‡± The Netherlands

    Rerolled the patch for tag 4.2.3

  • Patch #4 works for us in Drupal 10.2.3 and VBO 4.2.6, thank you!

  • Issue was unassigned.
  • Status changed to RTBC 2 months ago
  • πŸ‡ΊπŸ‡ΈUnited States joshf

    This also fixed the error for us; thanks for the patch!

  • Status changed to Postponed: needs info 2 months ago
  • πŸ‡΅πŸ‡±Poland Graber

    From steps to reproduce:

    Delete the row entry in the 'node' table with the id of one of the created nodes.

    That's not something we normally do, do we all agree? I could think of 100 more ways to break Drupal or VBO by corrupting its database.

    Do we have a way to reproduce this without making changes directly on the site database?

  • πŸ‡΅πŸ‡±Poland Graber

    If no, I recommend a post-update hook to fix corrupt data on the project, find out how does it get created and prevent that from happening, it may cause other issues elsewhere.

Production build 0.71.5 2024