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 #2957931: An AJAX HTTP error occurred when a user and its content is being deleted 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

Add an access check to prevent deletion if the user does not have the ability to break the lock. This is much better than the current redirect solution.

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

alexpott created an issue. See original summary.

alexpott’s picture

Title: Check if entities are locked on the delete confirm form » Use an access check to prevent deleting entities if the user does not have break lock permission
Issue summary: View changes
alexpott’s picture

Status: Active » Needs review
chr.fritsch’s picture

Status: Needs review » Needs work

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)

alexpott’s picture

Status: Needs work » Needs review

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.

chr.fritsch’s picture

Status: Needs review » Reviewed & tested by the community

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

  • alexpott committed b6f2d348 on 3.x
    Issue #3525533 by alexpott, chr.fritsch: Use an access check to prevent...
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.