Download & Extend

Duplicate key warnings generated on node_save()

Project:Primary Term
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:rmjiv
Status:reviewed & tested by the community

Issue Summary

Not sure why this doesn't happen when saving a node edit form, but with a programmatic node_save() of a node with a primary term assigned, duplicate key warnings on term_node are generated. As the comments say:

// taxonomy_node_save() allows $node->taxonomy to contain tids,
// term objects, or arrays of tids (keyed by vocabulary).  So,
// we can add the PT tid to the end of the array.

But, the code is only handling raw tids and arrays, not objects. The attached patch addresses this.

AttachmentSize
primary_term.module.patch435 bytes

Comments

#1

Status:active» reviewed & tested by the community

#2

Assigned to:Anonymous» sethcohn

+1, I know this stretch of code has some other patches pending on that same bit of logic, so I'll review and combine with this in mind.

#3

This patch and the one in http://drupal.org/node/604076 are essentially duplicates. They cover slightly different cases for the same problem. Here is a patch for the code I've been running for the past year on our site. It should cover both cases.

AttachmentSize
primary_term-357331-3.patch 950 bytes

#4

Thanks rmjiv,

This patch worked for me.

#5

Version:6.x-1.0» 6.x-1.x-dev
Status:reviewed & tested by the community» fixed

Committed mikeryan's patch to -dev. Both of the two submitted patches did the job; mikeryan's was easier to read for future maintainers.

http://drupal.org/cvs?commit=435604

#6

Status:fixed» closed (fixed)

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

#7

Assigned to:sethcohn» rmjiv
Status:closed (fixed)» needs review

Unfortunately mikeryan's patch didn't have a fix that is required for Hierarchical Select support. HS stomps on the keys in the $node->taxonomy array. The values are still there, but it's not keyed by tid anymore. Attached patch works around this.

AttachmentSize
primary_term-357331-7.patch 540 bytes

#8

Status:needs review» reviewed & tested by the community

worked fine for me. here is a formatted patch to make the mantainers' life easier.
see http://drupal.org/node/1054616 for more on this.

AttachmentSize
357331-duplicate-warnings-on-node-save-8.patch 850 bytes
nobody click here