Uninstall: Domain field data not cleared if much data

Created on 25 July 2023, 11 months ago

Drupal Version

9.5.8

Domain module version

1.0.0-beta8

Expected Behavior

No domain related errors should occur after uninstalling the module.

Actual Behavior

I get the error The "domain" entity type does not exist. while running the cron.
The error is the same as described in #2939640 πŸ› The "domain" entity type does not exist. Fixed .

Steps to reproduce

Have many entities with a "domain field" like domain_access.
Uninstall the module and run the cron.

The error occurs for the same reason as described in #2939640 πŸ› The "domain" entity type does not exist. Fixed .
The fix described there has the problem that it clears a max amount of field data during the uninstallation (50 in my case). If more data exists than what is specified in the batch size config, then it won't be cleared and the error occurs.

As a workaround, I changed the uninstall hook as follows:

function domain_uninstall() {
  // Do a pass of purging on deleted Field API data, if any exists.
  field_purge_batch(PHP_INT_MAX);
  \Drupal::entityTypeManager()->clearCachedDefinitions();
}

This works, but is not a clean solution. It might also run into a timeout, depending on the amount of data and the PHP config.

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡¨πŸ‡­Switzerland GRcwolf

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

Comments & Activities

Production build 0.69.0 2024