Problem/Motivation
I discovered this with a site that had uninstalled forum module, but I think it's a generic entity issue. Opening as critical because it's data loss, and reproducible 100% via the UI with core.
Steps to reproduce
1. Install the standard profile
2. Create a new 'discussions' node type
3. Re-use the 'comment_forum' comments field.
4. Create a discussion.
5. Comment on the discussion
6. Delete any terms in the forums vocabulary (because you won't be able to uninstall unless you do)
7. Uninstall forum module
8. SELECT * FROM comment_field_data; - the comment is still there
9. SELECT * FROM comment__comment_body; - the comment body is still in the database for now, but it's been marked as deleted.
10. Browse to comment/1 You will get Error: Call to a member function getSetting() on null in Drupal\comment\Controller\CommentController->commentPermalink() (line 129 of core/modules/comment/src/Controller/CommentController.php
However if you install forum, post a comment, then try to delete the comment_forum bundle, you get this in the UI:
Comment_forum is used by the node.comment_forum field on your site. You can not remove this comment type until you have removed the field.
Comment_forum is used by 1 comment on your site. You can not remove this comment type until you have removed all of the Comment_forum comments.
Proposed resolution
Not sure yet. We should not allow deleting bundles when there is content for that bundle in the database, so maybe adding this to validation, which would then prevent uninstall until the entities are deleted (similar to what is already done with taxonomy terms) would work. Then it wouldn't matter that we also delete the fields associated with the bundles and you wouldn't end up with invalid entities in the database.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet