Skip to content
This repository has been archived by the owner on Aug 15, 2021. It is now read-only.

Commit

Permalink
Merge function now cleans up duplicate tags on an entry. Fixes #2
Browse files Browse the repository at this point in the history
  • Loading branch information
tachyondecay committed Jul 8, 2012
1 parent 57ef373 commit 8aa6d56
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/class.tagmanager.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ public static function merge($field_id, $tags) {
"`handle` = '" . Symphony::Database()->cleanValue($tag) . "'"
);
}

// Clean up duplicate tags on an entry caused by the merge
$duplicates = Symphony::Database()->fetch(sprintf(
"SELECT id, entry_id, value FROM tbl_entries_data_%d a WHERE value = '%s' GROUP BY entry_id HAVING count(value) > 1",
$field_id,
$primary_value
));

foreach($duplicates as $dup) {
Symphony::Database()->delete('tbl_entries_data_' . $field_id, '`id` = ' . $dup['id']);
}
}

public static function update($field_id, $old_handle, $new_value) {
Expand Down

0 comments on commit 8aa6d56

Please sign in to comment.