This is a child issue of #2906470: Orphan comments and entries in comment_entity_statistics after comment field instance has been deleted. Based on the recommendation by @andypost and @larowlan, this UI part should be handled as a separate child issue.

Problem/Motivation

When a comment field instance is deleted for example from a node content type, we are currently showing the warning below.
Current warning

The site builder is currently not being explicitly warned that deleting the comment field will also delete all the comments of that comment field instance.

Proposed resolution

In addition to the current "Are you sure you want to delete the field {Comment field name}? This action cannot be undone." warning, the site builder should be shown a message: All comments of this comment field will be deleted.

If we want to make this more generic and to improve the site builder UX for all field deletions, we could re-phrase the This action cannot be undone warning as All content of this field will be permanently deleted. This action cannot be undone.

Remaining tasks

  • Decide if we want to make Comment module specific warning or improve this so that the same warning will be shown for all field deletions.
  • Patch
  • Review
  • Commit

User interface changes

Yes, see proposed resolution above.

API changes

None.

Data model changes

None.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

masipila created an issue. See original summary.

masipila’s picture

Issue summary: View changes
FileSize
27.05 KB
andypost’s picture

Issue tags: +Needs tests

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.

dillix’s picture

Is this issue actual?

andypost’s picture

Yes, it still makes sense to warn user about deletion of all comments the deleted field provides

msankhala’s picture

@masipila I think to make a generic deletion message for all fields make more sense and easiest to do. Deletion question is coming from Drupal/Core/Entity/EntityDeleteFormTrait::getQuestion() and description is coming from Drupal/Core/Entity/EntityConfirmFormBase::getDescription() We can simply change getDescription to return warning as well.

To make Comment module specific warning will require more work and testing. Thoughts?

masipila’s picture

The more generic approach sounds like a plan to me!

msankhala’s picture

Simplest possible solution.

msankhala’s picture

Status: Active » Needs review
bhanuprakashnani’s picture

Status: Needs review » Reviewed & tested by the community

The patch applies cleanly. The changes made are sufficient.

andypost’s picture

Status: Reviewed & tested by the community » Needs work

no-go for global override, probably comment module should alter \Drupal\field_ui\Form\FieldConfigDeleteForm when comment field is deleted

msankhala’s picture

Assigned: Unassigned » msankhala
msankhala’s picture

@andypost This is not a global override. We are modifying the global field delete message and adding a warning to the message, which kind of make sense to show a warning that If you delete this field all the content of this field are going to be deleted permanently. Thoughts?

Can you please give input on how can comment module alter \Drupal\field_ui\Form\FieldConfigDeleteForm if comment field is being deleted. There is a \Drupal\comment\Form\CommentTypeDeleteForm but this is for comment type deletion.

andypost’s picture

msankhala’s picture

Screenshot after applying this patch.
Field delete warning message

msankhala’s picture

Issue tags: -Needs screenshots
andypost’s picture

@msankhala thanx, now check delete form for any other field...

That's why I suggest to override comment delete form only to point that only comments from this field will be deleted
Basically not every field will delete some entities - guess paragraphs will need that as well)

+++ b/core/lib/Drupal/Core/Entity/EntityConfirmFormBase.php
@@ -24,7 +24,7 @@ public function getBaseFormId() {
-    return $this->t('This action cannot be undone.');
+    return '<p>' . $this->t('<strong>Warning:</strong> All the contents of this field will be deleted permanently. This action cannot be undone.') . '</p>';

what is "All the contents" means in scope of any field?

msankhala’s picture

@andypost I think 'All the contents' is not that confusing because if you are deleting a field then definitely all the contents of that field are going to be deleted, no matter what kind of field is that.
But I am happy to override this message only for comment field. I'll need your help in this. Do we need a new class something like \Drupal\comment\Form\CommentFeildConfigDeleteForm which will extend \Drupal\Core\Entity\EntityDeleteForm? or there is any better approach?

andypost’s picture

@msankhala I think better to add hook form_id alter cos you need to change only a message for specific condition

msankhala’s picture

Here is a new patch to display warning message specific to comment field deletion. Do we really need a test for this? We can create another issue to test this.

msankhala’s picture

Assigned: msankhala » Unassigned
Status: Needs work » Needs review
bhanuprakashnani’s picture

FileSize
655 bytes

I made the interdiff for the patches 8 and 21.

dravenk’s picture

Status: Needs review » Needs work

@msankhala

I was test patch #21 , It is little confused

1. create a article and submit comment
2. git apply comment-field-delete-form-warning-2908607-21.patch
3. delete field comment from article type
4. goto comment manager page /admin/content/comment

You will see the comment still here but clicking the comment link leads to errors. The actual situation is inconsistent with the description.

masipila’s picture

Status: Needs work » Postponed

Re #24: that's because the parent issue has not landed yet.

Postponing this on #2906470: Orphan comments and entries in comment_entity_statistics after comment field instance has been deleted.

msankhala’s picture

@dravenk Thanks for reviewing. Yes as @masipila mentioned actual comment not being deleted is related to another issue. The scope of this issue is only showing the proper warning message on comment field delete form.

dravenk’s picture

Status: Postponed » Reviewed & tested by the community

@masipila
Thank you for finding the reason. Now that looks good.

masipila’s picture

Status: Reviewed & tested by the community » Postponed

Thanks for taking the time to review and test @dravenk! I'm changing the status back to 'Postponed' so that this won't be accidentally committed before the parent issue lands.

msankhala’s picture

@masipila I think this has no dependency on the related issue, this is only about showing the warning. I think this can be committed. No?

masipila’s picture

Well to me it would be confusing to the max to show an explicit warning in the UI that 'comments will be deleted if you proceed' and then leave orphans to the database.

It already confused a contributor in #24 so I can only imagine the amount of confusion it would create in an average site builder.

I'll leave the decision to the comment module maintainers and core committers, this is just my 2 cents.

Cheers,
Markus

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.