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.
Not sure if this was overlooked or a feature but at the moment i can't see nothing stopping taxonomy removing a relationship on term_save, as taxonomy removes the relationship and then re-inserts it and that's the problem because there is no relationship to re-insert.
I am experiencing the above mentioned bug at the moment.
Comment | File | Size | Author |
---|---|---|---|
#3 | 1015722-3.patch | 2.16 KB | BrockBoland |
#1 | taxonomy_vocab_relate_relation_cache.patch | 1.47 KB | droid19 |
Comments
Comment #1
droid19 CreditAttribution: droid19 commentedI've created a patch which has seemed to fix the issue for me. Kinda new to patching so if the file is not of the correct format feel free to update.
Also you need to use the attached install file to create the new table which will cache and restore the relationships.
Looks like I can't attach .install files, so either create the table yourself or copy and paste the following into a .install file:
Comment #2
andrew.lansdowne CreditAttribution: andrew.lansdowne commentedI have had the same problem:
Say you have a parent vocab and child, where the child is set to be related to the parent, then you add terms to the child and set relations up to the parent one. Then if you edit the parent term and save, it deletes all the child->parent relations for that parent term.
A workaround I have found is to set the vocab relate on both taxonomies. So parent is related to child and child is related to parent. Then when you edit a term in parent there is a 'related terms in child' with all of them ticked, and it doesn't loose any.
If that is not an option then your fix seems like the only way to fix it (haven't tried it though).
Comment #3
BrockBoland CreditAttribution: BrockBoland commentedI'm seeing this same problem. It's caused by
taxonomy_save_term()
, which deletes any relationship that includes the term being edited, then re-saves the relationships from the form. In normal usage, this is fine, because a relationship with terms in the same vocabulary would remain selected in the multi-select box.I would like to propose a different solution, though. I wanted to avoid adding the DB overhead and an extra table, so I implemented a fix that only requires changes to existing functions in the module.
This patch adds to the
taxonomy_vocab_relate_form_alter()
function. It will now load up "opposing" relations - those where a term in another vocabulary has a relationship to the term being edited. These are stored in an array in the $form array, so that they are available intaxonomy_vocab_relate_term_submit()
, where they are re-saved.Comment #4
Coupon Code Swap CreditAttribution: Coupon Code Swap commentedI tried the patch and it is causing duplicate relationships.
Comment #5
BrockBoland CreditAttribution: BrockBoland commentedundoIT: Have you applied any other patches from this module's issues? Which version of Drupal core are you running? Could you try saving from both directions - save the term that has a relationship to the other term, and save the term that has a relation from another term?
Comment #6
andrew.lansdowne CreditAttribution: andrew.lansdowne commentedThis also happens when you re-order terms in the List Terms page. It loses relations and synonyms. It is a long-standing bug in core, since if you use the core functionality to add related terms within the same vocab and then reorder those terms, the relations are also lost! Link to core issue: http://drupal.org/node/251255
The patch from #57 in the link above seems to work for Drupal 6 to keep term relations when you re-order. Contributed modules which call taxonomy_save_term may still cause it to lose all the relations (and synonyms).
To fix the issue in this thread you still need to either enable relationship both ways, or apply one of the patches. I suggest you apply the core patch as well to avoid losing relations when you order terms.