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.
Hello,
Submit handler for adding or removing a parent for a term will load the term, based on $form_state values, run a query to update hierarchy table and after that it calls taxonomy_term_save($term), using the non-updated $term object.
That means we'll not have the new parents ids in the taxonomy_term_presave hook and for remove handler, the parents can't be removed, because even if db_delete will update the table, the taxonomy_term_save function will put parents back.
The key part is to replace the db_insert()/db_delete() part with populating the $term object with new parents ids.
Comment | File | Size | Author |
---|---|---|---|
#1 | parents_update-1972256-1.patch | 2.74 KB | Cracu |
Comments
Comment #0.0
Cracu CreditAttribution: Cracu commentedupdated message
Comment #0.1
Cracu CreditAttribution: Cracu commentedupdate message.
Comment #1
Cracu CreditAttribution: Cracu commentedI propose the attached patch.
Comment #2
Cracu CreditAttribution: Cracu commentedComment #2.0
Cracu CreditAttribution: Cracu commentednoticed also a bug.
Comment #2.1
Cracu CreditAttribution: Cracu commentedUpdated message
Comment #3
Cracu CreditAttribution: Cracu commentedUpdating status to review the patch.
Comment #4
mfernea CreditAttribution: mfernea commentedI confirm that the patch at #1 works.
Comment #5
mh86 CreditAttribution: mh86 commentedThanks for the patch and review!
Committed #1.
Comment #6.0
(not verified) CreditAttribution: commentedUpdate message.