Removing a tag via "My Tags" list doesn't work, when I am the node author

David Stosik - September 13, 2007 - 16:35
Project:Community Tags
Version:5.x-1.x-dev
Component:Code
Category:bug report
Priority:critical
Assigned:David Stosik
Status:needs review
Description

Hello, here is what I experienced:
I create a node, with some tag associated to it.
Then, I display this node. In "MyTags" section, I see all tags I put before, and I can remove one by clicking on it. But when I click on one tag, it disappears, but is still associated to the node...
Is there some easy action to correct this, or, maybe, to hide "MyTags" section to the node author?

Thank you for your help,
David

#1

David Stosik - September 21, 2007 - 13:18
Title:Remonving a tag via "My Tags" list doesn't work» Removing a tag via "My Tags" list doesn't work, when I am the node author
Assigned to:Anonymous» David Stosik
Status:active» needs review

What I did: display "My Tags" form to the node's author.
Patch is attached.

Thanks for your feedback.

AttachmentSize
community_tags_hide_mytags_to_author.patch 3.08 KB

#2

David Stosik - October 22, 2007 - 15:38

Hello,
Does anyone have the same problem as me?
I previous update, I meant "What I did: hide "My Tags" form to the node's author."

Please anyone tell me if he encounters this problem.

Thanks,
David

#3

jonathan_hunt - October 25, 2007 - 04:14

Yes, I get the same problem. I am adding a tag inline on a node, then deleting it, but the node stays categorised with that term (the term still appears in the tagadelic block).

#4

David Stosik - October 30, 2007 - 09:51
Priority:normal» critical

Hello,
At line 548, we can see this code:

<?php
if (!$is_owner) {
 
$placeholders = implode(',', array_fill(0, count($community_tagged), '%d'));
 
$result = db_query('SELECT n.tid, n.nid FROM {term_node} n LEFT JOIN {community_tags} c ON n.tid = c.tid AND n.nid = c.nid INNER JOIN {term_data} d ON n.tid = d.tid WHERE n.nid = %d AND c.nid IS NULL AND d.vid IN ('. $placeholders .')', $nid, $community_tagged);
  while (
$tag = db_fetch_object($result)) {
   
db_query('DELETE FROM {term_node} WHERE nid = %d AND tid = %d', $tag->nid, $tag->tid);
  }
}
?>

The code above doesn't work, unless community_tags uses only the taxonomy with tid=1. (when $placeholders = "%d" and $community_tagged is an Array, converted to integer 1 by db_query)
Actually, the db_query syntax doesn't allow to pass the query, then a variable, then a table of other variables. You have to pass the query, then either each variable, or a table containing all the variables.
I suggest to modify the code to have:
<?php
if (!$is_owner) {
 
$placeholders = implode(',', array_fill(0, count($community_tagged), '%d'));
 
// line above creates a "%d,%d,%d,...", string with as much %d as there are taxonomies used by community_tags
  // prepend the nid to the front of the variables array to be passed to db_query
 
$vars_array = $community_tagged;
 
array_unshift($vars_array, $nid);
 
$result = db_query('SELECT n.tid, n.nid FROM {term_node} n LEFT JOIN {community_tags} c ON n.tid = c.tid AND n.nid = c.nid INNER JOIN {term_data} d ON n.tid = d.tid WHERE n.nid = %d AND c.nid IS NULL AND d.vid IN ('. $placeholders .')', $vars_array);
  while (
$tag = db_fetch_object($result)) {
   
db_query('DELETE FROM {term_node} WHERE nid = %d AND tid = %d', $tag->nid, $tag->tid);
  }
}
?>

Where we pass an array containing the node id, then all the concerned vocabularies ids.
Now, when a user deletes his community tag, it is also deleted from term_node, if nobody else had also tagged the node.

Please let me know what you think of this modification.

Thanks,
David

#5

David Stosik - November 13, 2007 - 09:36

Hello?
I think this bug must be corrected as soon as possible.
Please answer to my request. :)

David

#6

stamd - June 29, 2008 - 18:19

hi...

i was having this problem too in addition to another big problem described here

http://drupal.org/node/159479

after applying the patch at the end of http://drupal.org/node/159479 I think it's also fixed the issue here, at least i no longer currently see it on my site.

this is the actual patch

--- /tmp/community_tags/community_tags.module   2008-02-19 21:59:22.000000000 +1100
+++ community_tags.module   2008-06-25 19:37:39.000000000 +1000
@@ -582,7 +582,9 @@ function community_tags_taxonomy_node_sa
   // Match real tags to community tags, if necessary (e.g. after quick tagging).
   if (!$is_owner) {
     $placeholders = implode(',', array_fill(0, count($community_tagged), '%d'));
-    $result = db_query('SELECT n.tid, n.nid FROM {term_node} n LEFT JOIN {community_tags} c ON n.tid = c.tid AND n.nid = c.nid INNER JOIN {term_data} d ON n.tid = d.tid WHERE n.nid = %d AND c.nid IS NULL AND d.vid IN ('. $placeholders .')', $nid, $community_tagged);
+    $args = $community_tagged;
+    array_unshift($args, $nid);
+    $result = db_query('SELECT n.tid, n.nid FROM {term_node} n LEFT JOIN {community_tags} c ON n.tid = c.tid AND n.nid = c.nid INNER JOIN {term_data} d ON n.tid = d.tid WHERE n.nid = %d AND c.nid IS NULL AND d.vid IN ('. $placeholders .')', $args);
     while ($tag = db_fetch_object($result)) {
       db_query('DELETE FROM {term_node} WHERE nid = %d AND tid = %d', $tag->nid, $tag->tid);
     }

 
 

Drupal is a registered trademark of Dries Buytaert.