_nat_update_terms() does not preserve term weight

MMachnik - October 24, 2008 - 15:23
Project:Node Auto Term [NAT]
Version:5.x-2.1
Component:Code
Category:bug report
Priority:normal
Assigned:Zen
Status:closed
Description

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

#1

miche - October 31, 2008 - 21:57
Status:active» needs review

+1

#2

anantagati - November 10, 2008 - 21:37
Status:needs review» reviewed & tested by the community

Looks good for me.

#3

Zen - February 14, 2009 - 18:18
Assigned to:Anonymous» Zen
Status:reviewed & tested by the community» fixed

Committed to D6 and D5.

Thanks for the patch and review :)
-K

#4

System Message - February 28, 2009 - 18:20
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.