Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
To reproduce this bug on a standard Drupal install:
1. Create an article node with 3 terms "x, y, z"
2. Using the taxonomy term edit form delete the x term.
3. Visit the node - you will see only the z term
4. Edit the node - you will get php notices Notice: Trying to get property of non-object in taxonomy_implode_tags() .
I've marked this as critical for two reasons - on step 3 the y term is missing and on step 4 you get php errors.
The issue seems to be that taxonomy_term_delete is not removing the term information from the field tables but it is removing it from the taxonomy tables.
Comment | File | Size | Author |
---|---|---|---|
#7 | 783112.patch | 3.63 KB | cha0s |
#5 | taxonomy_term_delete_2.patch | 3.95 KB | alexpott |
#1 | 783112_taxonomy_term_delete.patch | 1.69 KB | alexpott |
Comments
Comment #1
alexpottHere is a patch that adds a test for the above issue. Obviously it currently fails :)
Comment #2
alexpottInvestigations so far:
Taxonomy_term_delete calls field_attach_delete('taxonomy_term', $term) but this is doing nothing as the entity type the data is stored on is the node not taxonomy_term.
Comment #3
catchThere is currently no way for modules which provide reference fields to update field API about edits or deletions of the referenced entities.
The approach taken in D6 nodereference and userreference has been to account for stale data, and I think taxonomy reference field mostly follows that pattern, looks like we need to do the same in this particular case.
Actually updating field storage runs into the same issues as #556022: When a text format is deleted, some modules (like text.module) don't update their data, even though we say they do which is a minefield.
Let's watch the test fail.
Comment #5
alexpottHere's a patch that fixes both (3) and (4) from the issue post. It only includes a test for (3) so far.
It works in the way suggest by catch - basically it ignores field data that isn't a valid taxonomy term.
Comment #6
alexpottOops forgot to set to review... on you go testbot!
Comment #7
cha0s CreditAttribution: cha0s commentedFixed some whitespace issues in the patch, and changed a variable name in the test to be more descriptive.
Comment #8
Remon CreditAttribution: Remon commentedTested on todays drupal dev version, and works as explained
Comment #9
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks.