diff options
author | Neil Drumm <drumm@3064.no-reply.drupal.org> | 2006-05-23 02:21:26 +0000 |
---|---|---|
committer | Neil Drumm <drumm@3064.no-reply.drupal.org> | 2006-05-23 02:21:26 +0000 |
commit | 70b7809121ad00542bcd37545bf314d7215a72e6 (patch) | |
tree | 97b8efddec79c1a66dee150527298a577e9afc67 /modules | |
parent | 7aa1963abadc78e2868e94ef4ed73e9bb45bfb73 (diff) | |
download | brdo-70b7809121ad00542bcd37545bf314d7215a72e6.tar.gz brdo-70b7809121ad00542bcd37545bf314d7215a72e6.tar.bz2 |
#41042 by DriesK, Moshe, and Jaza, Duplicate tag handling
Diffstat (limited to 'modules')
-rw-r--r-- | modules/taxonomy.module | 9 | ||||
-rw-r--r-- | modules/taxonomy/taxonomy.module | 9 |
2 files changed, 14 insertions, 4 deletions
diff --git a/modules/taxonomy.module b/modules/taxonomy.module index a756654f6..2d3eb7c72 100644 --- a/modules/taxonomy.module +++ b/modules/taxonomy.module @@ -734,8 +734,9 @@ function taxonomy_node_save($nid, $terms) { // this, "somecmpany, llc", "and ""this"" w,o.rks", foo bar $regexp = '%(?:^|,\ *)("(?>[^"]*)(?>""[^"]* )*"|(?: [^",]*))%x'; preg_match_all($regexp, $vid_value, $matches); - $typed_terms = $matches[1]; + $typed_terms = array_unique($matches[1]); + $inserted = array(); foreach ($typed_terms as $typed_term) { // If a user has escaped a term (to demonstrate that it is a group, // or includes a comma or quote character), we remove the escape @@ -760,7 +761,11 @@ function taxonomy_node_save($nid, $terms) { $typed_term_tid = $edit['tid']; } - db_query('INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)', $nid, $typed_term_tid); + // Defend against duplicate, different cased tags + if (!isset($inserted[$typed_term_tid])) { + db_query('INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)', $nid, $typed_term_tid); + $inserted[$typed_term_tid] = TRUE; + } } } } diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index a756654f6..2d3eb7c72 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -734,8 +734,9 @@ function taxonomy_node_save($nid, $terms) { // this, "somecmpany, llc", "and ""this"" w,o.rks", foo bar $regexp = '%(?:^|,\ *)("(?>[^"]*)(?>""[^"]* )*"|(?: [^",]*))%x'; preg_match_all($regexp, $vid_value, $matches); - $typed_terms = $matches[1]; + $typed_terms = array_unique($matches[1]); + $inserted = array(); foreach ($typed_terms as $typed_term) { // If a user has escaped a term (to demonstrate that it is a group, // or includes a comma or quote character), we remove the escape @@ -760,7 +761,11 @@ function taxonomy_node_save($nid, $terms) { $typed_term_tid = $edit['tid']; } - db_query('INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)', $nid, $typed_term_tid); + // Defend against duplicate, different cased tags + if (!isset($inserted[$typed_term_tid])) { + db_query('INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)', $nid, $typed_term_tid); + $inserted[$typed_term_tid] = TRUE; + } } } } |