Closed (fixed)
Project:
Drupal core
Version:
x.y.z
Component:
taxonomy.module
Priority:
Minor
Category:
Bug report
Assigned:
Reporter:
Created:
13 Dec 2005 at 18:10 UTC
Updated:
6 Jun 2006 at 02:30 UTC
Jump to comment: Most recent file
When freetagging an item, and using the same tag twice, a database error will occur. For example: linux, eeg, linux, super-fries
The linux tag will yield:
Warning: Duplicate entry '2-1' for key 1 query: INSERT INTO term_node (nid, tid) VALUES (1, 2) in /drupal-cvs/includes/database.mysql.inc on line 108
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | free_tag_dupes_0.patch | 1.38 KB | Jaza |
| #12 | free_tag_dupes.diff | 1.49 KB | moshe weitzman |
| #5 | unique_tags.patch | 727 bytes | DriesK |
Comments
Comment #1
junyor commentedDuplicate of http://drupal.org/node/40945.
Comment #2
adam.skinner commentedThis is not a duplicate issue. Please note that this occurs when entering the same tag twice for a node using freetagging.
Comment #3
moshe weitzman commentedwhat kind of fool adds same tag twice?
Comment #4
junyor commentedHow is this by design? What if you add it accidentally? That shouldn't cause a DB error.
Comment #5
DriesK commentedAlthough chances of this happening are small, I agree with Junyor that when someone uses the same tag twice by accident, this shouldn't cause a db error.
I don't think we need to issue a form error and instruct the user to remove the duplicate. Instead, I suggest we let Drupal handle this silently (see attached patch).
Comment #6
dries commentedRelated to http://drupal.org/node/37829 ?
Comment #7
adam.skinner commentedPatch works great!
I don't suppose you'd believe me if I told you I tried the same thing but it didn't work for me before. I must have put it in the wrong place (I'm not really a php coder, but I found the array_unique function and put it in where it looked like it belonged).
Anyway, that fixed the problem! Thanks DriesK!
Comment #8
adam.skinner commentedI'm going to leave this as "ready to be committed", but I would like to bring up one outstanding issue: capitalization. array_unique doesn't do the case-insensitivity thing, so if we put in "linux, pancakes, Linux, home-skillet", we'll get the duplicate node error.
Obviously, the downside of lower-casing the whole thing is that when new taxonomy terms get added, they would be added without the original casing.
Comment #9
Cvbge commentedAre freetags lowecased? If not, "linux" and "Linux" are 2 different tags.
Comment #10
adam.skinner commentedWhen a tag is inserted via freetagging, it retains it's case. So if you tag something "Linux", it will insert "Linux" as the name in term_data. Thereafter, whether you put in "LiNUx" or "linux", it will find the term and associate it. So tag matching is not case-sensitive, but tag insertion retains case.
Comment #11
dries commentedSo I guess this needs more work?
It would be nice to look at http://drupal.org/node/37829 as well.
Comment #12
moshe weitzman commentedi added some more defensiveness so we don't attempt an insert when adding two terms of slightly different case
Comment #13
dries commentedCorrect me if I'm wrong, but even with the extra defensiveness, it's prone to errors? I guess the only way to fix it is to do a SELECT-query before the INSERT-query (while holding a table lock).
Comment #14
moshe weitzman commented@Dries - you are correct. I'd rather not lock for every taxonomy add/edit. I'd say that his is good enough for now. My .02
Comment #15
dries commentedEven without a table lock, one can have duplicates, I'm afraid. Please set back to RTBC if I'm wrong.
Comment #16
morbus iffFor what it's worth, and I'm just spouting here because I"ve not yet looked more in-depth into the patch, duplicates should be case-sensitive. If Dries makes a revolutionary window washing technique, "Dries" and "dries" are quite different freetags, and should remain as such. (Worst. Example. EVAH!)
Comment #17
Egon Bianchet commentedStill present in 4.7.0
Comment #18
Jaza commentedPatch for latest HEAD / 4.7. Same as #12 by moshe, except that in_array() check has been changed to isset().
Oh, and did I mention +1 for this idea?
Comment #19
killes@www.drop.org commentedApplied to 4.7
Comment #20
drummCommitted to HEAD.
Comment #21
(not verified) commented