Message "Required by Drupal (Fields Pending Deletion)" baffles users

Created on 4 November 2011, over 13 years ago
Updated 10 July 2025, 5 days ago

Problem/Motivation

When disabling modules that create fields this error is sometimes displayed. The message does not make it clear what caused the issue or how to fix it which is frustrating for users.

If you want to fix the underlying issue that causes this message check out #943772: field_delete_field() and others fail for inactive fields β†’

The reason the fields are not deleted immediately on uninstall is that the database could be very, very large, and deleting all fields at the same time might time out the request, leaving the database in an unknown state. That's why cron is used to delete the fields.

Proposed resolution

Change message to be more descriptive and more helpful in resolving the issue

There are Fields pending deletion that were created by a module you just tried to disable. Delete offending fields now or try running cron, it might fix this issue.

The error message is produced by field_system_info_alter() in core/modules/field/field.module.

Also, give the user a report of how many such field entries exist, and if there are more than some arbitrary threshold, don't allow the user to try to delete them all at once.

Remaining tasks

  1. Write a patch

Original report by [joachim]

I saw this message in my modules list and it completely baffled me.
I only found out I had to run cron thanks to a comment buried in an issue on a contrib module somewhere.
When this text appears in the module admin page it should be linked to further help.

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component

base system

Created by

πŸ‡¬πŸ‡§United Kingdom joachim

Live updates comments and jobs are added and updated live.
  • Needs backport to D7

    After being applied to the 8.x branch, it should be considered for backport to the 7.x branch. Note: This tag should generally remain even after the backport has been written, approved, and committed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States damienmckenna NH, USA

    Would it be useful to indicate which fields are pending deletion? I've ran into this problem a few times, most recently because a layout field wasn't fully deleted and it's taking a lot of effort to find the root of the problem. This is what I used to find the field names:

      public function validate($module) {
        $reasons = [];
        if ($field_storages = $this->getFieldStoragesByModule($module)) {
          // Provide an explanation message (only mention pending deletions if there
          // remain no actual, non-deleted fields.)
          $fields_in_use = $fields_deleted = [];
          foreach ($field_storages as $field_storage) {
            if (!$field_storage->isDeleted()) {
              $fields_in_use[$field_storage->getType()][] = $field_storage->getLabel();
            }
            else {
              $fields_deleted[] = $field_storage->getType();
            }
          }
          if (!empty($fields_in_use)) {
            foreach ($fields_in_use as $field_type => $field_storages) {
              $field_type_label = $this->getFieldTypeLabel($field_type);
              $reasons[] = $this->formatPlural(count($fields_in_use[$field_type]), 'The %field_type_label field type is used in the following field: @fields', 'The %field_type_label field type is used in the following fields: @fields', ['%field_type_label' => $field_type_label, '@fields' => implode(', ', $field_storages)]);
            }
          }
          else {
            $reasons[] = $this->t('Fields pending deletion: @fields', [
              '@fields' => implode(', ', $fields_deleted),
            ]);
          }
        }
        return $reasons;
      }
    
Production build 0.71.5 2024