To replicate issue:
Conditions
the content type is a blog entry (or whatever)
Actions
Load a taxonomy term
And assign it to the content
This works fine if a person has not manually chosen the same taxonomy term already, but if they have it throws an error. This is because both the node form and the Rules actions are trying to insert the same entry.
Likewise, this will also happen if you simply try to Edit the form later and submit (as the taxonomy term will be autofilled in the form).
user warning: Duplicate entry '4-31' for key 'PRIMARY' query: INSERT INTO term_node (nid, vid, tid) VALUES (20, 31, 4) in /Users/username/Sites/whatever/modules/taxonomy/taxonomy.module on line 698.
More validation is needed to prevent this.
Comments
Comment #1
fagoRules does only
and then saves the node and that only if term isn't there yet. Thus a simple load and save should be fine? So with which event can reproduce that? Perhaps somehow after the node has been saved after a node edit?
Comment #2
Anonymous (not verified) commentedYou can reproduce this with what I posted above.
Actions
Load a taxonomy term
And assign it to the content
Then in your node form, manually add the same taxonomy term that Rules is going to Load and Assign. So the taxonomy term will be submitted via the standard user-entered taxonomy form field and Rules.
OR
Create a node. Save. Edit. Save.
Comment #3
fagoBut where stems the node from? Which event are you using?
Comment #4
webkenny commented@fago, sorry for that. we both are working this issue. The event is "Content is about to be saved".
Comment #5
kevin hankens commentedThe issue is that fixed vocabularies come through in the node object as:
$node->taxonomy[$taxonomy_term->tid]
where tag vocabularies come through as:
$node->taxonomy['tags'][[delta]]
Here is a patch for rules/modules/taxonomy.rules.inc that also checks to see that the term to add is not an existing tag. I hope this helps!
Comment #6
webkenny commentedWorks for me. Thanks Kevin.
Comment #7
fagoI see, however $node->taxonomy['tags'] might not be initialized. I suppose in this case this fix will produce an warning.
Comment #8
micnap commentedThis fixed it for me. Thanks!
Mickey
Comment #9
fagoAs this bug-report is rather old, please verify it's still valid in the latest dev version and re-open if so. For now, I'm marking it as closed.