Redirect on cron Node delete with lock

Created on 8 February 2024, 10 months ago
Updated 30 July 2024, 4 months ago

Problem/Motivation

When we are trying to delete a node using Drupal API on cron and the node has a lock on it triggers a redirect back to the node and it breaks cron.

      use Drupal\node\Entity\Node;
      $nids = ['123'];
      $entity_type_repository = \Drupal::service('entity_type.repository');
      $entity_type_manager = \Drupal::entityTypeManager();
      $storage = $entity_type_manager->getStorage($entity_type_repository->getEntityTypeFromClass(Node::class));
      $nodes = $storage->loadMultiple($nids);
      $storage->delete($nodes);

Steps to reproduce

1. Create a node and put a lock on it
2. Create a cron where you will be deleting this node.
3. Get a transaction rollback because it's locked
4. Get redirected to the node view page.

Proposed resolution

If if call is not from the UI pass the lock.

πŸ› Bug report
Status

Postponed: needs info

Version

2.0

Component

Code

Created by

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

Comments & Activities

Production build 0.71.5 2024