I have a problem with the removing of terms from content.

$node->taxonomy is keyed off the vocabulary id ($taxonomy_term->vid) and not the term id ($taxonomy_term->tid).

I am thinking that both:

  rules_action_taxonomy_term_assign_to_content
  rules_action_taxonomy_term_remove_from_content

are using $taxonomy_term->tid like this:

  if (!isset($node->taxonomy[$taxonomy_term->tid])) {

and I think it needs to use the vid like this:

  if (!isset($node->taxonomy[$taxonomy_term->vid])) {

Here is a patch that should update both the vid issue as well has handling adding and removing single and multi-select vocabulary terms.

Is it a problem to always "return array('node' => $node);" even if the $node didn't change?

CommentFileSizeAuthor
#1 rules-v2.diff1.58 KBhawk259
rules.diff1.78 KBhawk259

Comments

hawk259’s picture

Component: Rules Core » Rules Engine
StatusFileSize
new1.58 KB

Sorry, rules.diff is a old diff. Please use this one rules-v2.diff (removed the free form tag removing code as it is not needed).

fago’s picture

Status: Active » Needs work

hm, I think $node looks different depending on the stage in the node editing process. Afaik token has also some troubles with that. So if you can make the code more robust, +1 for that.
However your patch has some tabs in it, please make sure the follow the drupal coding standards http://drupal.org/coding-standards

I'd also prefer to have another tester who verifies that it stays working, as I've never used that one.

>Is it a problem to always "return array('node' => $node);" even if the $node didn't change?
Yes it would be saved for nothing. So only do that, if you have changes to save.

hawk259’s picture

Your right, $node->taxonomy bounces around with the format:

http://drupal.org/node/379564

I will follow up with a new patch once I work out the details of the above bug.

fago’s picture

Status: Needs work » Fixed

in the meanwhile there are such actions.

Status: Fixed » Closed (fixed)

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