When using a module like VBO or Media Mover to programmatically re-save nodes, autotagging attempts to duplicate node_term relationships which already exist in the node, resulting in a user warning for each term in place.

Comments

lightsurge’s picture

Status: Needs work » Active

I'm guessing this might be something to do with it?

http://api.drupal.org/api/drupal/modules--taxonomy--taxonomy.module/func...

For some reason on node_load the taxonomy terms aren't in a format that can currently be dealt with properly by autotagging? I'm not a programmer, although I've hacked around a bit but with no success coming up with a fix.

Sample of warning (one for each pre-existing term):

user warning: Duplicate entry '199-170' for key 1 query: INSERT INTO term_node (nid, vid, tid) VALUES (170, 170, 199) in /modules/taxonomy/taxonomy.module on line 719.

lightsurge’s picture

Status: Active » Needs work

As I don't need to be able to change tags on a programmatic node_save, I just added this code:

$keys=array_keys($node->taxonomy);
$objectMode=is_object($node->taxonomy[$keys[0]]);
if ($objectMode) {
$taxonomy=module_invoke("taxonomy","nodeapi",$node,'load');
$node->taxonomy=$taxonomy['taxonomy'];
}

Which won't be a solution for everyone. But I couldn't work out how to get $node->taxonomy dealt with properly... So this just invokes taxonomy nodeapi to replace it.

Status: Active » Needs work