Problem/Motivation

Protection against accidental data loss is implemented inconsistently and makes it difficult and time consuming to make and deploy content model changes. Consider a few examples:

Via the Drupal UI...

Try to delete a content type with existing nodes.
Drupal refuses: "Example is used by 1 piece of content on your site. You can not remove this content type until you have removed all of the
Example content."
Try to delete a vocabulary with existing terms.
Drupal allows with warning: "Deleting a vocabulary will delete all the terms in it. This action cannot be undone."
Try to delete a field with data in it.
Drupal allows without any mention of the field containing data.
Try to change configuration of a field with data in it.
Drupal refuses: "There is data for this field in the database. The field settings can no longer be changed."

Try to do deploy prohibited changes via configuration import and the whole operation will abort:

$ drush config-import -y
 Collection  Config                                         Operation
             core.entity_view_display.node.example.default  delete
             core.entity_view_display.node.example.teaser   delete
             core.entity_form_display.node.example.default  delete
             field.field.node.example.body                  delete
             field.field.node.example.field_example         delete
             node.type.example                              delete
[error] Import the listed configuration changes? (y/n): y
Drupal\Core\Config\ConfigImporterException: There were errors validating the config synchronization. in Drupal\Core\Config\ConfigImporter->validate() (line 728 of
/var/www/example/docroot/core/lib/Drupal/Core/Config/ConfigImporter.php).
[error] The import failed due for the following reasons:
Entities exist of type Content and Content type Example. These entities need to be deleted before importing.


The impact is that any project team tasked with significant or ongoing changes to the content model will spend a lot of time puzzling over inconsistent error messages, deleting content from local dev environments in order to make configuration changes, and writing update hooks in order to deploy them. The most skilled of teams will be slowed considerably. Junior teams are likely to get blocked.

Proposed resolution

  1. Settle on and consistently implement a pattern in the UI that...
    1. Warns when an action will cause data loss.
    2. Provides an option to accept the loss (e.g., "Delete all Example nodes and continue.").
  2. Provide an override for the ConfigImporter validation routine allowing configuration changes causing data loss to be imported so that Drush and other tools can use it.

Remaining tasks

TBD

User interface changes

TBD

API changes

TBD

Data model changes

TBD

Comments

TravisCarden created an issue. See original summary.

anavarre’s picture

Priority: Normal » Major

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

anavarre’s picture

Issue tags: +Entity Field API
anavarre’s picture

Issue tags: -Entity Field API

Per @berdir, tag isn't correct indeed.

Few thoughts:

15:17 <berdir> anavarre: also, I agree that it should be easier. but it's not really about data loss or not. it's about having a way to purge that data or not. if you delete a node type and still have nodes, your site will die with fatal errors
15:19 <berdir> anavarre: and fields have the purge system and integrates it into the config importer and deletes all affected content.. would be nice to have that too for content entities with bundles, agreed :)
15:21 <anavarre> berdir: I'll capture this in the issue. I guess the request here is mostly about consistency and a scary warning message saying if you do want to delete all your nodes in a content type as a consequence of your actions, then so be it
15:21 <berdir> anavarre: agreed, that would be nice, also in the UI, especially for entity types that might not provide an easy way to do bulk delete
15:22 <berdir> anavarre: https://www.drupal.org/project/paragraphs/issues/2764681 is a related issue where we are trying to implement that specifically for paragraphs, in the UI only
webchick’s picture

Tagging for UX team review.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

catch’s picture

Category: Bug report » Plan

The taxonomy module example shouldn't exist in its current state, it was ported from 7.x which was similarly broken. I opened #3396838: Deleting a vocabulary will fail when there are lots of terms to change it to match the content type example.

Eventually, we could add batch/queue support for deleting unbounded numbers of the same entities, but until we have that, we shouldn't be attempting to load and delete potentially millions of entities within a form submission.

I think this is more of a plan (that could have bug reports as child issues), but agreed it's a problem.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.