CCK field altering makes taxonomy_defaults try to re-add taxonomy
hamaldus - February 10, 2009 - 15:28
| Project: | Taxonomy Defaults |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | postponed (maintainer needs more info) |
Description
It seems that when using comment_cck, taxonomy_defaults tries to re-add the taxonomy to the term_node table. This results in a user warning, like this following:
user warning: Duplicate entry '33-131' for key 1 query: INSERT INTO term_node (nid, vid, tid) VALUES (17, 131, 33) in /home/.quiterie/user/mysite.org/modules/taxonomy/taxonomy.module on line 702.
I am using comment_cck and taxonomy_defaults. Everything works fine, exept for this warning.
This does NOT happen when editing the node the regular way, aka node/x/edit.

#1
I'm unable to reproduce this. Could you describe your setup in more detail? On a fresh install, how would I create this scenario?
Also, are you using any other taxonomy/cck crossover modules, like cck_taxonomy?
#2
In addition to the two above, I use
taxonomy_breadcrumb
taxonomy_image
taxonomy_manager
hiearchical_select
no crossovers cck/taxonomy
Ive tried disabling taxonomy_defaults on the main installation, the error goes away.
i have now set up a fresh install aiming to reproduce the error.
-Installed comment_cck and taxonomy_defaults.
-Created a userreference field on story, allowed it to be edited by comment_cck.
-Created a node, commented on it while editing the userreference field.
Works fine here too, no success in reproducing the error.
I will dig a little deeper in my main installation tomorrow to see if there are conflicts i have overseen.
#3
I'm seeing the same bug when I'm using Views Bulk Operations. When I run any of the operations on a set of selected nodes exposed through the view, I get a message like the following:
user warning: Duplicate entry '55-51' for key 1 query: INSERT INTO term_node (nid, vid, tid) VALUES (51, 51, 55) in /www/modules/taxonomy/taxonomy.module on line 702.In my case, taxonomy_defaults is using taxonomy_defaults_nodeapi() as I haven't exposed the taxonomies to the content types directly.
#4
Problem seems to appear when node_save is issued from the code (i.e. after Views Bulk Operations action). In this case node's taxonomy property has tid as index, not vid. In this case taxonomy_defaults_nodeapi would not simple override exiting tid element, but add a new one even if default tid already exists.
Attached quick patch I am not really happy with, but at least it gets rid of this error.
#5
#6
Yes, the patch works for bulk operations with no warnings, but resaving nodes that have already had their default terms assigned causes the following warning to appear:
warning: current(): Passed variable is not an array or object in /www/sites/all/modules/taxonomy_defaults/taxonomy_defaults.module on line 92.#7
Could one of you test this process on the 6.x-1.1-beta release? I've completely removed the taxonomy_defaults_nodeapi function that the patch above alters, and I think it's pretty likely that this issue has gone away -- that function was poorly thought out and created lots of interaction problems with other modules.
Note that you MUST run the update script after installing the beta, and you'll need to enable "hidden" vocabularies on the vocabulary admin pages and then hide them on the taxonomy_defaults admin page. Cumbersome, I know -- but the cost of fixing a broken architecture.