Check if entities are locked on the delete confirm form

Created on 20 May 2025, 16 days ago

Problem/Motivation

If there are entities which are locked and you use the multiple delete capability of bulk actions then you will get exceptions and odd error messages. Ideally a user should be prompted to unlock the entities prior to deleting.

Note a recent change πŸ› An AJAX HTTP error occurred when a user and its content is being deleted Needs review that is probably too liberal. I think that change in pre-delete breaks the ideal flow of content lock - which is warning a user and getting them to unlock prior to taking an action.

Steps to reproduce

Use bulk actions to delete entities that are locked.

Proposed resolution

Check for locked entities on the entity delete confirm form.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

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

Merge Requests

Comments & Activities

  • Issue created by @alexpott
  • πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ
  • πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ
  • πŸ‡©πŸ‡ͺGermany chr.fritsch πŸ‡©πŸ‡ͺπŸ‡ͺπŸ‡ΊπŸŒ

    I tested this in Thunder 7.4.x. I created an article and went to the edit page, so the article is locked. I went back to the content overview and wanted to delete the article.
    Then I got the following error message:

    
    The website encountered an unexpected error. Try again later.
    
    TypeError: Drupal\content_lock\Event\ContentLockReleaseEvent::__construct(): Argument #3 ($formOp) must be of type string, null given, called in /var/www/html/docroot/modules/contrib/content_lock/src/ContentLock/ContentLock.php on line 153 in Drupal\content_lock\Event\ContentLockReleaseEvent->__construct() (line 17 of modules/contrib/content_lock/src/Event/ContentLockReleaseEvent.php).
    
    Drupal\content_lock\ContentLock\ContentLock->release() (Line: 207)
    content_lock_entity_delete()
    call_user_func_array() (Line: 416)
    Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}() (Line: 395)
    Drupal\Core\Extension\ModuleHandler->invokeAllWith() (Line: 415)
    Drupal\Core\Extension\ModuleHandler->invokeAll() (Line: 217)
    Drupal\Core\Entity\EntityStorageBase->invokeHook() (Line: 900)
    Drupal\Core\Entity\ContentEntityStorageBase->invokeHook() (Line: 462)
    Drupal\Core\Entity\EntityStorageBase->delete() (Line: 753)
    Drupal\Core\Entity\Sql\SqlContentEntityStorage->delete() (Line: 362)
    Drupal\Core\Entity\EntityBase->delete() (Line: 71)
    Drupal\Core\Entity\ContentEntityDeleteForm->submitForm()
    call_user_func_array() (Line: 129)
    Drupal\Core\Form\FormSubmitter->executeSubmitHandlers() (Line: 67)
    Drupal\Core\Form\FormSubmitter->doSubmitForm() (Line: 597)
    Drupal\Core\Form\FormBuilder->processForm() (Line: 144)
    Drupal\autosave_form\Form\AutosaveFormBuilder->processForm() (Line: 326)
    Drupal\Core\Form\FormBuilder->buildForm() (Line: 97)
    Drupal\autosave_form\Form\AutosaveFormBuilder->buildForm() (Line: 73)
    Drupal\Core\Controller\FormController->getContentResult()
    call_user_func_array() (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
    Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
    Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
    Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 116)
    Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 90)
    Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
    Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 741)
    Drupal\Core\DrupalKernel->handle() (Line: 19)
    
    
  • πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

    Fixed the error reported in #5 - I think this is a bug in 3.x but it is good to catch it and fix it here because it is caused by deleting entities with form op locking enabled.

  • πŸ‡©πŸ‡ͺGermany chr.fritsch πŸ‡©πŸ‡ͺπŸ‡ͺπŸ‡ΊπŸŒ

    This looks really good to me. The flow makes much more sense now

  • Pipeline finished with Skipped
    2 days ago
    #513164
    • alexpott β†’ committed b6f2d348 on 3.x
      Issue #3525533 by alexpott, chr.fritsch: Use an access check to prevent...
  • πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ
Production build 0.71.5 2024