Delete community tag
rcourtna - January 8, 2008 - 05:05
| Project: | Community Tags |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | patch (code needs review) |
Jump to:
Description
Hi, Not sure if the following is a bug/issue, or if it's by design:
- add community tag "foo" to a node not owned by the current user
- "foo" appears as a community tag, and as a "real" tag (term for the node)
- delete my community tag "foo"
- "foo" no longer appears a community tag, however it still exists as a "real" tag
Shouldn't the "real" tag be deleted as well (assuming of course that nobody else also tagged the node with "foo" as well)?
Thanks
Ryan
PS: this is a great module!

#1
Well, this could go as a clean-up after removal.
#2
I ran into this same behavior, which I classed as a bug, and made my own fix with the following code, which not only deletes the "real tag" references, but also deletes the tag from the vocabulary if no other node is tagged with it (this code appended to the bottom of function 'community_tags_taxonomy_node_save()');
<?php$result = db_query('SELECT tid FROM term_node a LEFT JOIN community_tags b USING (tid) WHERE a.nid = %d AND b.nid IS NULL', $nid);
while ($orphan_tag = db_fetch_object($result)) {
db_query('DELETE FROM term_node WHERE tid = %d AND nid = %d', $orphan_tag->tid, $nid);
$res2 = db_fetch_object(db_query('SELECT count(*) AS count FROM term_node WHERE tid = %d', $orphan_tag->tid));
if (!$res2->count) {
db_query('DELETE FROM term_data WHERE tid = %d', $orphan_tag->tid);
db_query('DELETE FROM term_hierarchy WHERE tid = %d', $orphan_tag->tid);
db_query('UPDATE sequences SET id = (SELECT max(tid) FROM term_data) WHERE name = \'term_data_tid\'');
}
}
?>
#3
This looks like a duplicate of #175416: Removing a tag via "My Tags" list doesn't work, when I am the node author.
#4
Perhaps not actually, as the other issue refers to own nodes, while this refers to others.