Deleted entity id's on content_lock table make cron to fail

Created on 13 January 2025, 4 months ago

Problem/Motivation

Content lock module errors make cron to fail with Drupal 10.4.x. leading to e.g. scheduling not work at all.

A nonexisting entity ID in the content_lock table cause following error:

 [error]  TypeError: Drupal\content_lock\ContentLock\ContentLock::release(): Argument #1 ($entity) must be of type Drupal\Core\Entity\EntityInterface, null given, called in /app/web/modules/contrib/content_lock/modules/content_lock_timeout/content_lock_timeout.module on line 42 in Drupal\content_lock\ContentLock\ContentLock->release() (line 138 of /app/web/modules/contrib/content_lock/src/ContentLock/ContentLock.php) #0 /app/web/modules/contrib/content_lock/modules/content_lock_timeout/content_lock_timeout.module(42): Drupal\content_lock\ContentLock\ContentLock->release(NULL, 'edit', '1')

Steps to reproduce

Configure content lock to release locks automatically on cron and ensure node entity is configured to locked on edit.

  • Create a node
  • Node get locked, see content_lock table get a row with that entity_id
  • Delete the node by clicking "delete" in the node edit form
  • See content_lock table still has that entity_id
  • Wait until content lock timeout is bypassed
  • Run cron and it should fail with the error message above

Proposed solution

Ensure deleted entity id's are removed from the content_lock table to avoid this issue.

Will provide a patch in comment for this.

Next steps

I am proposing to decide how the content_lock_timeout.module should deal with entity id's that do not exist and make it failsafe.

🐛 Bug report
Status

Active

Version

3.0

Component

Code

Created by

🇫🇮Finland kirkkala Helsinki

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

Comments & Activities

Production build 0.71.5 2024