Closed (fixed)
Project:
Rules
Version:
6.x-1.3
Component:
Rules Engine
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
15 Sep 2009 at 09:39 UTC
Updated:
14 Jan 2011 at 17:12 UTC
Jump to comment: Most recent file
Comments
Comment #1
klausiDoes not seem to be Rules Forms related.
Comment #2
adpo commentedIndeed, It is not about Rules Forms but Triggered rules. Does anyone had a similar issue with rules and found an answer? Thank you for reply.
Comment #3
scholesy commentedwhat I did was make a call to:
taxonomy_node_delete(..)
in function rules_action_taxonomy_term_remove_from_content(..) in taxonomy.rules.inc instead of all the things that the function is originally doing, and that seems to fix the problem.
hope this helps.
Comment #4
adpo commentedThank you I will try
Comment #5
costas vassilakis commentedHi scholesy ,
I have the same problem,
How did you make this call (taxonomy_node_delete(..))
Can you provide a more detailed code?
Comment #6
scholesy commentedOK, what I did was just replace what was inside function rules_action_taxonomy_term_remove_from_content, so the function now is simply:
/**
* Action: Remove a term from content.
*/
function rules_action_taxonomy_term_remove_from_content($node, $taxonomy_term, $settings) {
taxonomy_node_delete($node);
}
Hope this helps.
Comment #7
kunago commentedI cannot agree with the fix posted in #6 as this would remove all the associations from a node. All that is desired is to remove one single term.
I created this patch that resolves it for me. A little bit of explanation for the code.
The taxonomy module in Rules assumes that the taxonomy terms are stored in $node->taxonomy[$taxonomy_term->tid]. Experimentally I found it this is not true. If there is one vocabulary assigned to a content type, the path would be $node->taxonomy['delta'] => $taxonomy->tid. If there are more than one vocabularies, the path is $node->taxonomy['taxonomy-field-number'][$taxonomy->tid] => $taxonomy->tid. I hope I got this right.
Anyway, in the patch I am using a recursive search in array function that browses $node->taxonomy and tries to find the $taxonomy->tid in it. If it does find it, it then based on how deep the term is, it unsets the variable and therefore removes the term from the node.
The code is running on my site and does what is expected from it. I am not familiar with the way of adding new functions to the code, what is the way to create the functions' names, variables, etc. So please do make the changes to the code so that it respects the Rules module's coding.
Comment #8
kunago commentedResubmitting the patch with Unix-style line endings.
Comment #9
kunago commentedNew patch submit for testing.
Comment #11
klausiThis patch contains absolute paths, make sure that you create the patch from the module folder which should give relative paths.
Comment #12
kunago commentedWill this do?
Sorry, but I am using WinMerge to create the patch and don't know how to tweak the patch file so it passes through the testing procedure.
Comment #13
klausihttp://drupal.org/patch/create
as you seem to use windows: http://drupal.org/node/60234
Comment #14
kunago commentedI followed the guide and don't know why the patches don't validate...
So one more try.
EDIT: This time the patch is being ignored by Simpletest. Any volunteers willing to test, feel free.
Comment #15
klausiComment #17
melchoir55 commentedsubscribe
Comment #18
melchoir55 commentedAttempted to apply your patch. Cygwin just hung up when it was ordered to apply it. I'm guessing it isn't compiled properly.
edit:
Manually applied patch. Appears to be functioning as intended.
I recommend fixing the patch such that it can be added.
Comment #19
kunago commentedCreating such a patch will need to be the task for someone who knows how because I tried several times following step-by-step manuals which never made it work. For some reason I am unable to create the patch on Windows with WinMerge.
Comment #20
lucio.ferrari commentedI humbly disagree with post #7, I tried to implement the patched function via custom php action and it didn't work.
"The taxonomy module in Rules assumes that the taxonomy terms are stored in $node->taxonomy[$taxonomy_term->tid]", and it does indeed, in fact by using the standard code for the function:
in an 'execute PHP' block, the taxonomy term is removed.
I think the problem is quite deeper, maybe it depends on when the function is called, though I tried to trigger the rule when 'content is going to be saved' AND 'after updating/saving content'. Neither works.
Comment #21
lucio.ferrari commentedWhoops, I guess I didn't implement the function correctly, it does work, my kudos!
To use it as an 'execute custom php' - since I'm not so keen to directly modify modules - i rewrote it as:
Incidentally, the action 'assing term to content' is equally flawed: it tries to assign the term even when the term is already assigned. This results in a SQL error, since the table entry in 'node_term' already exists.
The problem is the same, because the
if(!isset ... )check doesn't find the right value in the array, it assumes it doesn't exists and proceeds to duplicate it.This means - as kunago correctly pointed out - that the $node object which is passed to the action is not the same you get with
node_load($nid);, in which the terms are objects nested into the $node->taxonomy array.In post #7 kunago says that it is instead in
What is 'taxonomy-field-number'...?
Comment #22
lucio.ferrari commentedLatest release fixed the problem.