Problem/Motivation

A child taxonomy term is automatically deleted when it only has one parent term and that parent is deleted. In one delete submission, multiple terms can be deleted, but the user is never fully informed of the deleted terms. Neither before or after confirmation of the deletion. In this situation, users might not realize which terms are actually deleted.

After completion of the operation, the produced log notice only include the root deleted term. Leaving no trace to help a confused user who don;t understand why a term he did not delete disappeared.

When the user is asked to confirm the deletion of a taxonomy term, a confusing "Deleting a term will delete all its children if there are any. This action cannot be undone." is displayed. This message is confusing because:

  • On the confirmation page, the user has no way to known if the term as any children.
  • The deletion is recursive (all descendants are affected, not just direct children). But the message usage of "children" fail to acknowledge it.
  • Any child of a deleted descendants that has a non-deleted parents will not be deleted. But the message fail to inform the user that some descendants may bot be deleted.

What behavior were you expecting?
Before confirmation of the operation, the user should be presented with a list of all taxonomy terms that will be deleted.
On completion of the delete operation, a confirmation message including the list of all the deleted taxonomy terms, and a matching log notice.

What happened instead?
Before confirmation of the operation, a confusing "Deleting a term will delete all its children if there are any. This action cannot be undone." message.
One confirmation message reading "Deleted term Term1" with a matching log notice.

Steps to reproduce

  1. Create a taxonomy term, Term1
  2. Create another taxonomy term, Term2, whose parent is Term1
  3. Delete Term1 (Term2 will then be deleted)

Proposed resolution

Override the methods used for confirmation messages and log to include the complete list of deleted terms.

Remaining tasks

  • Please review the attached patch and make suggestions as necessary.
  • Tests are needed.

Add links to before and after screenshots in the next section so the reviewer can find the latest ones.

User interface changes

Before

TBA

After

TBA

API changes

Data model changes

Release notes snippet

Note: Original reporter, @guschilds, came across this issue when debugging #726490: Taxonomy term record for term with multiple parents is not deleted when parent is deleted.

Issue fork drupal-1766486

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

guschilds’s picture

Status: Active » Needs review
StatusFileSize
new1.72 KB

Attaching the proposed solution.

guschilds’s picture

Actually, this patch moves the alerts to a more intelligent place. They now live in the same loop of postDelete as the check for orphans.

A message will be output for every term deleted, rather than only the single submitted deletion.

Status: Needs review » Needs work

The last submitted patch, 2: taxonomy-multiple-deletion-messages-1766486-2.patch, failed testing.

shipra.wasson’s picture

Status: Needs work » Needs review
Issue tags: +#SprintWeekend2015
StatusFileSize
new144.3 KB

The delete confirmation message alreay says " Deleting a term will delete all its children if there are any. This action cannot be undone. ". Attaching a screenshot .

David Hernández’s picture

Issue tags: -#SprintWeekend2015 +SprintWeekend2015

Hello!

Thank you for working on this issue!

We should all try and use the same sprint tag. According to https://groups.drupal.org/node/447258 it should be SprintWeekend2015 with no #.

mgifford’s picture

Status: Needs review » Needs work

Not sure why this is Needs review.

pbuyle’s picture

Assigned: Unassigned » pbuyle
Status: Needs work » Active
Issue tags: +SprintWeekend2016

I think @shipra.wasson used the review status because the current behavior is acceptable. Prior to deletion, the user is warned the children (if any) will be deleted. I guess Shipra didn't want to close the issue as "work as designed" but wait for some else confirmation that the current behavior was enough.

I tend to disagree, IMHO providing complete feedback on the deleted terms is indeed needed.

The message (and watchdog) logic are in ContentEntityDeleteForm::submitForm, but the logic to delete orphans terms is in Term::postDelete. The message and watchdog should be one in TermDeleteForm::submitForm, but there is no way to get the list of orphans after the call to parent::submitForm. In order to display the list of deleted term, the form would need its orphans detection logic prior to calling parent::submitForm to be able to display the list of deleted terms.

pbuyle’s picture

Assigned: pbuyle » Unassigned
Issue summary: View changes
Status: Active » Needs work
StatusFileSize
new7.13 KB

The attached patch provides more complete message and log.

However, I'm not satisfied with the complicated solution I ended up to nicely display a list of entity labels. Is there a better way to display a list of strings, each escaped as a emphasized placeholder?

Also, the added TermDeleteForm::getDeletedTerms() method is non-trivial and should be covered by some form of tests. Same for the list formatting logic. I've limited experience of testing in Drupal 8. How are this kind of stuffs usually tested? It could be tested via a web test, but that seems unnecessary complex. A unit test of the class seems easier to do.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.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.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.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.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.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.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.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.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should 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.

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

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should 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.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.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: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should 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.

pameeela’s picture

Version: 8.9.x-dev » 9.3.x-dev
Issue tags: +Bug Smash Initiative

Still valid in 9.3.x

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.

shalini_jha’s picture

I have able to reproduce the issues by following the steps in 11.x-dev.

shalini_jha’s picture

Status: Needs work » Needs review
StatusFileSize
new61.43 KB
new49.1 KB
new64.46 KB

Hi everyone,
I have taken reference from #9 and added all the required changes and added a Mr with test .
added screen shot for your reference.
please review.

dishakatariya’s picture

Assigned: Unassigned » dishakatariya
dishakatariya’s picture

Assigned: dishakatariya » Unassigned
Status: Needs review » Reviewed & tested by the community
StatusFileSize
new93.18 KB
new89 KB

Hi, I have verified and tested MR- merge_requests/6306 file on the 11.x version with.It is working as expected now.
Testing steps-
Install the Drupal 11.x version
Now go to the /structure/taxonomy and click on list terms
Now click to Add term
Add themultiple terms, set as one parent term and in that drag the other as child terms
Now click to save
and then click to the Delete operation
and now see on the popup which displays the parent term name with the child name as well with the notification.
Testing Result:
Orphan taxonomy terms are deleted with the notification.
Attaching screenshot for reference.
Thanks!

dishakatariya’s picture

StatusFileSize
new82.48 KB
new85.23 KB
quietone’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs issue summary update, +Usability

Oh, I do love older issues getting fixed. Thanks!

I'm triaging RTBC issues.

I checked the history and the issue summary was last updated in 2016, so I suspect it is out of date. Yes, it is it states that tests are needed but I some in the MR. It is a well written issue summary though. Easy to know what is being fixed here. I am tagging for an Issue Summary update. This is changing the UI so I am tagging for Usability. Since it does change the UI before and after screenshots should be available to the reviewer from the Issue Summary. I have updated the issue summary to the current standard template to help with the update.

I then read the comments. #9 states "I'm not satisfied with the complicated solution I ended up to nicely display a list of entity labels". That patch was converted to an MR and that code looks to be the same. That still needs to be addressed. And further, I do not a comment that anyone has done a code review.

There is a contributor task for https://www.drupal.org/community/contributor-guide/task/review-a-patch-or-merge-request that you may find helpful.

I have not reviewed the MR nor tested it.