When I create a blog post with three terms in the freetagging section, here's the mysql warning message I get:
* user warning: Duplicate entry '1-101' for key 1 query: INSERT INTO term_node (nid, tid) VALUES (101, 1) in /home/rockth5/public_html/stage/includes/database.mysql.inc on line 167.
* user warning: Duplicate entry '1-101' for key 1 query: INSERT INTO term_node (nid, tid) VALUES (101, 1) in /home/rockth5/public_html/stage/includes/database.mysql.inc on line 167.
* user warning: Duplicate entry '1-101' for key 1 query: INSERT INTO term_node (nid, tid) VALUES (101, 1) in /home/rockth5/public_html/stage/includes/database.mysql.inc on line 167.
Notice how each of these is trying to associate node 101 with term 1. It should be associating 101 with 37, 45, and 82 (examples). For it to be associating each of those with 1 means something's broken in the taxonomy wrapper.
This in turn prevents category from cooperating with Views and other taxonomy dependant modules.
Hope this helps!
Comments
Comment #1
baal32 commentedI'm having the same problem with the tid not being passed correctly to term_node
Comment #2
smoothify commentedI posted a possible solution on a different issue (regarding tagadelic), but the problem was the same.
Basically the insert routine for term_data wasn't keeping track of the auto increment id for the tag and so when it went to insert into term_node it would use an invalid one.
see http://drupal.org/node/119938 or below:
i've been looking at this today and think i found the problem with the free tagging.
Its in the taxonomy_save_term function, around line 337.
I added the following lines above the Insert routine:
Before the $edit['tid'] wasn't being set at all resulting in insert errors, or incorrect id's.
Sorry i don't have time for a patch, but this is now working for me.
Comment #3
venkat-rk commentedI just wonder if this bug is at the heart of all those duplicate entry errors that have been alive in many category related modules (and perhaps still are) ever since category was released. I read somewhere else on the forum in connection with some other module(s) that duplicate entry errors happen when the auto incrementing fails. Sorry I am unable to dig up the links.
Just wanted to share this observation.
Comment #4
smoothify commentedI have just run into some problems with my fix - the term_node and term_data table seem to occasionally get out of sync,
I think this is definitely the right area but we need to make sure its synced better with the category tables and also possibly put a lock on to prevent a race condition.
I will keep looking into this if i get a chance.
Comment #5
smoothify commentedI spent some time on this yesterday but didn't really get anywhere. I gave up in the end and uninstalled the module and returned to the basic drupal taxonomy module.
What i did find out though is when you insert / update a node using free tagging (and there are new categories to add) then the legacy routines in the wrapper get fired twice.
Once before the actual category node is created and once after. The problem here is the routine before the category node is added isn't aware of the id of the next category to be added, and the routine after isn't aware of the id of the node.
I think the taxonomy wrapper really needs an overhaul, to be simplified and most of the logic moved into the actual category module, as its so hard to work out exactly whats happening and in what order.
Will be following the progress though as i'd like to use category in my upcoming sites.
Ben
Comment #6
inforeto commentedPossible related issues, with fixes:
http://drupal.org/node/87669 (this one marked as fixed)
http://drupal.org/node/59163 (where terms > nodes)
Other related issues:
http://drupal.org/node/65355
http://drupal.org/node/89844
http://drupal.org/node/73668
Development threads:
http://drupal.org/node/53860
Related support requests:
http://drupal.org/node/76571
http://drupal.org/node/89545
http://drupal.org/node/111141
http://drupal.org/node/121386
Comment #7
mariagwyn commentedsubscribing. I am having a similar problem with the category module, freetags and updates.
Comment #8
lenart commentedSame problem here. I have category.module (5.x-1.x-dev from 2007-Mar-06), free-tagging and multiple select on containers (which is anyway true for free-tagging).
- If I choose existing terms it works fine
- If I remove or add other existing terms from the node it works fine
- If I add one non-existing term it works fine
- If I want to add two (or more) new terms it breaks
user warning: Duplicate entry '0-68' for key 1 query: INSERT INTO term_node (nid, tid) VALUES (68, 0) in /includes/database.mysql.inc on line 172.Comment #9
lenart commentedAfter some more debugging i've discovered this:
The problem lies in line 550 of category's taxonomy.module
db_query('INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)', $nid, $typed_term_tid);Obviously the variable $typed_term_tid is blank all the time when trying to insert the terms in the table.
Here's the output when I tried to freetag a node with three non-existing terms (captured before the INSERT INTO {term_node} statement):
I'm digging deeper now and I hope to find the problem. I assume it is in the loops around line 536.
P.S. I've also noticed that the table term_data is not cleaned up after deleting all nodes and their related categories.
Comment #10
pacesie commentedThe problem maybe clear already, just to leave another case of confirmation.
When I use one container with free tagging and one without, choosing one category in each when creating content results in:
It happens no matter whether the free tag is newly created or not. I am using drupal 5.1.
Comment #11
pacesie commentedWill this error leave some sort of problem in the database even I deleted all contents and categories that created this error?
Comment #12
inforeto commentedThe main effect is that nodes aren't associated with their proper taxonomies.
For corrections, editing of nodes and categories might be safer than manually working with the database.
Check the available threads on this subject.
http://drupal.org/node/87669
http://drupal.org/node/59163
etc.
Comment #13
mgerra commentedFound same problem on my 5.1 site yesterday. I'm using following:
Taxonomy - 1.330.2.2 2007/01/25
Category - 1.124.2.2 2007/02/02
Interestingly, I get the same errors:
user warning: Duplicate entry '1-280' for key 1 query: INSERT INTO term_node (nid, tid) VALUES (280, 1)
But, am not using free-tagging. Rather, I'm just trying to insert 2 different categories from 2 separate containers (vocabs) on my node form. Error goes away when I select only one category to add, regardless of which container it comes from.
Keen to help and find a solution.
Comment #14
schildi commentedHas somebody checked the patch provided by richardfullmer on http://drupal.org/node/121399 ?
Comment #15
sjh-1 commentedIf the patch above works, then this would be a duplicate of http://drupal.org/node/87669 I've submitted a slightly different patch there and some investigation into where the bug was introduced.
Comment #16
bdragon commentedMarking as duplicate of http://drupal.org/node/87669.
Thank you for your report.
--Brandon