Error when Comment module is disabled and Revisions are reassigned to Anonymous

Created on 23 February 2023, over 1 year ago
Updated 27 February 2023, over 1 year ago

Problem/Motivation

An error occurs if the Comment module is disabled.
Also, content revisions get assigned to the Anonymous user.

Steps to reproduce

Create a new Drupal 9 site.
Disable the Comment module if it is enabled.
Add new users (testuser1 and testuser2)
Log in as testuser1 and add content.
Edit content multiple times so revisions can be created.
Delete testuser1 and reassign content to testuser2.

If the Comment module is disabled, an error will occur.

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "comment" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition() (line 139 of /reassign_user/drupal/web/core/lib/Drupal/Core/Entity/EntityTypeManager.php).

If the Comment module is enabled, testuser1 will be deleted and its content will now be assigned to testuser2. However, the content revision will be assigned to the Anonymous user.

Proposed resolution

Update the revision_uid in the node_revision table
Update the uid in the content_moderation_state_field_revision table (this will reassign user content that is in draft mode)
Check if the content module exist before setting the comments variable.

πŸ› Bug report
Status

Fixed

Version

1.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.69.0 2024