Content remains tagged with a taxonomy term (via the {taxonomy_index} table) even after its corresponding term reference field is deleted and purged

Created on 18 February 2011, almost 14 years ago
Updated 22 July 2024, 5 months ago

Problem/Motivation

Deletion of a taxonomy field from a content type leaves references to affected nodes in taxonomy_index, which results in vocabulary terms remaining attached to those nodes.

Steps to replicate:

  1. Go to admin/structure/taxonomy/tags and add a new term.
  2. Go to admin/structure/types and add a new content type.
  3. On the “Manage fields” tab for the new content type, add a new term reference field using the select widget. Save and select the “tags” vocabulary on the field settings form.
  4. Go to node/add and add a node of the content type created in Step #2. Select the term you added in Step #1 in the field from Step #3 and save.
  5. Go to admin/structure/types and click on the "Manage fields" tab.
  6. Delete the term reference field created in Step #3.
  7. Go to admin/structure/taxonomy/tags and click on the tag created in Step #1.
  8. Observe that the node from Step #4 is still listed, despite that the field containing this term was removed from the content type.

Expected behaviour
You are given the message "If you have any content left in this field, it will be lost. This action cannot be undone." indicating that any tags given to content of this content type will be removed.

Actual behaviour
Content remains tagged with the vocabulary despite not having the field any more. These can be removed by readding the term reference field, removing the tags for the content and then removing the field again.

Proposed resolution

Deleting references by vocabulary is complicated by the potential for data loss if two taxonomy fields on a content type reference the same vocabulary. Proposed resolution is to clear and rebuild taxonomy_index. This may cause slowdown on large sites; suggested that it should run through Queue API.

Remaining tasks

This issue is currently waiting on a patch in #89181: Use queue API for node and comment, user, node multiple deletes .

User interface changes

Warning message noting the potential delay in taxonomy re-indexing and a link to cron for immediate rebuild if desired.

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Taxonomy 

Last updated 1 day ago

  • Maintained by
  • 🇺🇸United States @xjm
  • 🇬🇧United Kingdom @catch
Created by

🇬🇧United Kingdom ethiaa

Live updates comments and jobs are added and updated live.
  • Needs backport to D7

    After being applied to the 8.x branch, it should be considered for backport to the 7.x branch. Note: This tag should generally remain even after the backport has been written, approved, and committed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States damondt

    Just ran into this, steps to reproduce:
    - Site had existing term reference field
    - New term reference field added to facilitate manual content entry changes before feature launch
    - Original term reference field deleted on feature launch
    - Term pages show content for field that no longer exists

Production build 0.71.5 2024