Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Better cleanup when deleting Paragraph Types #166

Closed
laryn opened this issue Feb 16, 2024 · 1 comment
Closed

Better cleanup when deleting Paragraph Types #166

laryn opened this issue Feb 16, 2024 · 1 comment

Comments

@laryn
Copy link
Member

laryn commented Feb 16, 2024

I'm finding that deleting a Paragraph Type doesn't fully clean up -- the type and the field instances are removed, but if there are fields that were only used in that type, they remain in the configuration as orphans.

Right now we're manually deleting paragraphs field instances when deleting a paragraphs type (in paragraphs_bundle_delete):

  • paragraphs/paragraphs.module

    Lines 1139 to 1142 in e827b5a

    $sub_names = config_get_names_with_prefix('field.instance.paragraphs_item.' . $bundle->bundle . '.');
    foreach ($sub_names as $sub_name) {
    config($sub_name)->delete();
    }

When deleting the field instances, I think we should instead use field_instance_delete which will also give us an option to set the $field_cleanup parameter to TRUE and also delete the field itself if it is no longer in use:

@laryn
Copy link
Member Author

laryn commented Feb 16, 2024

It looks like a minor reorganization of code may be enough here. (Field cleanup defaults to TRUE in that function).

@laryn laryn closed this as completed in 631fd93 Feb 16, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant