Download & Extend

_nat_update_terms() does not preserve term weight

Project:Node Auto Term [NAT]
Version:5.x-2.1
Component:Code
Category:bug report
Priority:normal
Assigned:Zen
Status:closed (fixed)

Issue Summary

We have found that when doing node_save() on a node that uses NAT, if the node has an associated term with a weight other than 0, the weight gets reset to 0.

_nat_update_terms() defines the weight as 0 when it sets up the edit array and does not use the weight from the terms that are passed in. We solved the problem by taking the term weight and assigning it into $edit before calling taxonomy_save_term():

<?php
     $edit
['tid'] = $term->tid;
+
+    if (isset(
$term->weight)) {
+     
$edit['weight'] = $term->weight;
+    }
+
    
taxonomy_save_term($edit);
?>

Here is a patch that implements this. Thanks to miche for her help in solving this issue!

AttachmentSize
nat_preserve_term_weight.patch377 bytes

Comments

#1

Status:active» needs review

+1

#2

Status:needs review» reviewed & tested by the community

Looks good for me.

#3

Assigned to:Anonymous» Zen
Status:reviewed & tested by the community» fixed

Committed to D6 and D5.

Thanks for the patch and review :)
-K

#4

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.