I am trying to use VBO to selectively add taxonomy terms to nodes -- most of which already have several terms assigned -- without losing the existing terms. Unfortunately VBO not only adds the new term but removes all of the others. I don't see a way of getting round this.

I tried checking the box labelled "Add new value(s) to (Vocabulary), instead of overwriting the existing values" but this simply triggers another (known) problem, where multiple duplicates of the new term are created.

Comments

dwhutton’s picture

Title: When adding a new taxonomy term to a node, VBO removes existing terms » When adding a taxonomy term to a node, VBO duplicates existing terms

Update: changed title to clarify issue.

If I use VBO to list all nodes that contain 'bribery' in the body, and to add the taxonomy term 'Corruption' to each, some of these nodes (which already had that tag) will now be tagged TWICE with the term 'Corruption'. If similar VBO operations are repeated, some nodes may have three or more occurrences of the same taxonomy term.

Part of this issue is now resolved with a patch here http://drupal.org/node/1507216 which prevents duplicate terms (with different TIDs) being added to the VOCABULARY. However, VBO continues to add duplicate taxonomy terms (with the same TID) to the NODE -- if that node already had that term associated with it.

mimrock’s picture

I made a patch to make sure that no taxonomy reference is stored more than once in the same field of the same node.

mimrock’s picture

Status: Active » Needs review
dwhutton’s picture

Unfortunately this patch does not work on my site.

I suspect that this may be because the code does not handle multiple languages. My site has two languages (English and French) and all the taxonomy terms are associated with one language or the other.

mimrock’s picture

Status: Needs review » Needs work

That's possible.

vikramy’s picture

Patch #2 works for me. I don't have any multilingual site to test this but will try.

Andreas Radloff’s picture

#2 Works for me too, one language

bojanz’s picture

Title: When adding a taxonomy term to a node, VBO duplicates existing terms » Prevent storing duplicat references
Category: Bug report » Task
Issue summary: View changes
Status: Needs work » Fixed

Made it work for other reference fields as well (entityreference being the most important one), fixed the multilingual issue, add the PHP dependency since we're relying on a parameter introduced in PHP 5.2.9.

Committed:
http://drupalcode.org/project/views_bulk_operations.git/commitdiff/ddda8...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

mperrando’s picture

The fixing patch breaks the Drupal system requirement on the PHP minimum verison 5.2.5.

This can break an already running site that cannot be updated to PHP 5.2.9 (what ahppened to me).

Shouldn't this issue be reopened?

bojanz’s picture

No, I've explicitly added the dependency.
PHP 5.2.9 was released 5 years ago. If you're running a PHP version older than that, you can patch VBO yourself.