Problem/Motivation

field_purge_batch() tries to purge fields that have no instances. field_read_instances() does not return instances attached to unknown entity types unless include_inactive is set in the $include_additional parameter. If you delete field instances in the disable hook of a module that provides an entity type, those instances will not be automatically purged. However, the fields will be purged automatically. Every time you uninstall the module, it will leave instances that have no corresponding fields in the field_config_instances table. These orphaned instances can only be deleted manually.

Proposed resolution

Pass include_inactive in the $include_additional parameter before attempting to purge fields.

Remaining tasks

  1. Review patch.
  2. Commit patch.
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Darren Oh’s picture

Issue summary: View changes
FileSize
1.11 KB
Darren Oh’s picture

Assigned: Darren Oh » Unassigned
Darren Oh’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 1: drupal-field_purge_batch-2337139.patch, failed testing.

Darren Oh’s picture

FileSize
1.11 KB

Fixed typo.

Darren Oh’s picture

Status: Needs work » Needs review
Darren Oh’s picture

FileSize
1.16 KB

Changed wrong line.

Status: Needs review » Needs work

The last submitted patch, 7: drupal-field_purge_batch-2337139-7.patch, failed testing.

Darren Oh’s picture

Status: Needs work » Needs review
FileSize
1.17 KB
Darren Oh’s picture

Title: field_purge_batch() falsely assumes that instances attached to unknown entities do not exist » Fields with instances attached to unknown entities are deleted on cron run
Taran2L’s picture

Darren Oh’s picture

Status: Closed (duplicate) » Needs review

This is not a duplicate. The other patch would still allow fields with inactive instances to be deleted before the instances have been deleted.

mcdruid’s picture

Aren't the patches effectively exactly the same?

Darren Oh’s picture

No, this patch fixes field deletion and the other patch fixes instance deletion.