field_attach_delete_bundle should have $field_cleanup argument

Created on 8 November 2011, over 13 years ago
Updated 23 January 2025, about 1 month ago

WHAT

Function field_attach_delete_bundle is calling the field_delete_instance
The field_delete_instance has $field_cleanup = TRUE as a second argument which is responsible for preserving the field itselft when all it's instances are removed. In field_attach_delete_bundle this second argument is not provided so field_delete_instance is called in it's default state = it will remove the fields if all instances(bundles) are removed. So there should be argument $field_cleanup in field_attach_delete_bundle to prevent this.

WHY

If you have a custom entity and you have a set of fields that all its bundles should have attached to them and you delete all existing bundles the fields should not be deleted. Developer should have this option to choose if he wants to preserve the fields or not. In my case I have an install profile that will create an entity and one example bundle. If user deletes this bundle and he didnt created another item bundle before all fields will be deleted. Since the fields-set is a key component of the install profile they cant be deleted in any case. For now Ive duplicated the field_attach_delete_bundle so the fields wont be deleted. The change of this wont compromise functionality of this function in any way so its safe to change this function. I see it as a design flaw so im not marking it as a bug.

πŸ“Œ Task
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component

field system

Created by

Live updates comments and jobs are added and updated live.
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 smustgrave

    Thank you for creating this issue to improve Drupal.

    We are working to decide if this task is still relevant to a currently supported version of Drupal. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or is no longer relevant. Your thoughts on this will allow a decision to be made.

    Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

Production build 0.71.5 2024