_node_mass_update_batch_process fails during user cancel when revision is deleted

Created on 23 June 2024, 10 months ago

Problem/Motivation

In _node_mass_update_batch_process() we call _node_mass_update_helper() with the loaded node object or revision. If the node or revision is somehow deleted during the cancel process, the batch process fails with the error:
_node_mass_update_helper(): Argument #1 ($node) must be of type Drupal\node\NodeInterface, null given

Steps to reproduce

  1. Create a bunch of nodes for a user
  2. Cancel the user using user_cancel_reassign
  3. Delete one of the nodes of the user while the cancel process is running
  4. An error should be shown: _node_mass_update_helper(): Argument #1 ($node) must be of type Drupal\node\NodeInterface, null given

Proposed resolution

Check if the node or revision still exists before calling _node_mass_update_helper()

Remaining tasks

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

🐛 Bug report
Status

Active

Version

11.0 🔥

Component
Node system 

Last updated about 15 hours ago

No maintainer
Created by

🇳🇱Netherlands seanB Netherlands

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

Merge Requests

Comments & Activities

  • Issue created by @seanB
  • Status changed to Needs review 10 months ago
  • 🇳🇱Netherlands seanB Netherlands

    Created a PR.

  • Pipeline finished with Success
    10 months ago
    Total: 650s
    #206083
  • Status changed to Needs work 10 months ago
  • 🇺🇸United States smustgrave

    Think it needs a rebase showing 1000+ changes

  • Assigned to ankitv18
  • 🇮🇳India ankitv18

    @smustgrave target branch should be 11.0.x or 11.x?

  • 🇺🇸United States smustgrave

    Would let @seanB update the existing branch before we start opening bunch of new ones, since it's only been 1 hour.

  • Issue was unassigned.
  • 🇮🇳India ankitv18

    Alright @smustgrave

    @seanB could you try below code whether it's resolving the problem instead of if condition with instanceOf check.

    /** @var \Drupal\node\NodeStorageInterface $storage */
      $storage = \Drupal::entityTypeManager()->getStorage('node');
      $count = min(5, count($context['sandbox']['nodes']));
      for ($i = 1; $i <= $count; $i++) {
        // For each nid, load the node, reset the values, and save it.
        /** @var \Drupal\node\NodeInterface $node */
        $node = array_shift($context['sandbox']['nodes']);
        if ($load) {
          $node = $revisions ?
            $storage->loadRevision($node) : $storage->load($node);
        }
        $node = _node_mass_update_helper($node, $updates, $langcode);
  • 🇳🇱Netherlands seanB Netherlands
  • Pipeline finished with Canceled
    10 months ago
    Total: 193s
    #206588
  • Pipeline finished with Canceled
    10 months ago
    Total: 108s
    #206593
  • Pipeline finished with Failed
    10 months ago
    Total: 656s
    #206598
  • 🇮🇳India ankitv18

    MR!8505 seems quite messed up.

  • Pipeline finished with Failed
    10 months ago
    Total: 539s
    #206666
  • Pipeline finished with Success
    10 months ago
    Total: 762s
    #206690
  • Status changed to Needs review 10 months ago
  • 🇮🇳India ankitv18

    MR!8515 is ready for a review
    @seanB could you please check MR!8515 and check whether this resolve the issue.
    cc: @smustgrave

  • Status changed to Needs work 10 months ago
  • 🇺🇸United States smustgrave

    Would much rather of given @seanB a chance to update his MR, so now we got 2 one needs to be hidden.

    The latest MR does not match the summary.

    Tagging for tests based on the title, seems like a bug we should have coverage for.

  • 🇳🇱Netherlands seanB Netherlands

    MR!8515 does not solve the issue. If a node or revision is deleted during the batch process (by something or someone outside of the batch process), $node is NULL. This throws an error when trying to call _node_mass_update_helper.

  • 🇦🇺Australia acbramley

    I've closed 8515 as there were no functional changes there (just @var comments).

    8505 looks like it needs a rebase and we still need tests.

Production build 0.71.5 2024