After uninstalling the Mass Contact module, my status report lists the following error:

Entity/field definitions
Mismatched entity and/or field definitions
The following changes were detected in the entity type and field definitions.
User

The user.mass_contact_opt_out field needs to be uninstalled.

Running Drupal 10.6.5.

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

trolin created an issue. See original summary.

akash_deep made their first commit to this issue’s fork.

akash_deep’s picture

Working on this

akash_deep’s picture

fixed the two issues in hook_uninstall() - added the missing leading backslash on the Drupal::configFactory() calls and corrected a typo in the docblock. The field should now be properly removed when the module is uninstalled.

akash_deep’s picture

Status: Active » Needs review
vinodhini.e’s picture

Status: Needs review » Needs work

Hi, Tested this module on Drupal 10.5.1.

Reproduced the issue:

  • Installed the module and verified the mass_contact_opt_out field is created on the User entity.
  • Uninstalled the module.
  • Navigated to Status report page.

Observed error:

Mismatched entity and/or field definitions – The user.mass_contact_opt_out field needs to be uninstalled.

Applied merge request !8.

  • Reinstalled the module.
  • Assigned opt-out option for a few users (to ensure field usage).
  • Uninstalled the module again and cleared cache.

The issue still persists after applying the patch. The patch in MR !8 does not fully resolve the issue.
The field is still not properly removed during module uninstall.

akash_deep’s picture

Hi @vinodhini.e, thanks for testing that. You were right, the fix wasn't working because mass_contact_opt_out is a base field defined in hook_entity_base_field_info, not a config field. So the configFactory calls had nothing to delete. I've updated the MR to use entityDefinitionUpdateManager instead which is the proper way to remove base fields on uninstall. Could you please give it another test when you have time?

akash_deep’s picture

Status: Needs work » Needs review
vinodhini.e’s picture

Hi, @akash_deep,

I followed the below steps:

  • Applied the provided patch and cleared cache
  • Installed the module and assigned the mass_contact_opt_out field to a user
  • Uninstalled the module and cleared cache again

However, the issue still persists. It still shows the following message on the status report page:

Mismatched entity and/or field definitions
The following changes were detected in the entity type and field definitions:
User: The user.mass_contact_opt_out field needs to be installed.

The patch does not resolve the issue as expected. Thanks.