Jump to:
| Project: | Rules |
| Version: | 6.x-1.x-dev |
| Component: | Rules Engine |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
When I create a rule, add an action, I put the info I need... it works great. Say this was a "Load Term". Now I have a variable "taxonomy term".
Add some other actions...
Then I want to load another term. That fails with the error "variable already exists" (I don't know the exact error, but that's what it means).
The problem here is that the 2nd time I try to load a term, the system checks that there won't be a clash between variable names. The system takes the name from the array describing the "Load Term" functionality and uses it as is.
What I'd suggest is that instead of using the name as is, it would be to add the rule number at the end. For most actions it probably isn't a problem, but for the "Load Term", since you first have to define the taxonomy, it fails and you are not given a chance to fix the variable name.
So something like: "set variable name to default name + rule #" would solve the problem 99% of the time (the other 1% are people who change the name and somehow the name still clashes with an existing name.)
Another way, if that's easy enough, would be to define the variable name, check whether it is already defined, if so, add a number at the end (i.e. _1). If that also exists, increment the number (i.e. _2). Do so until you find a name that's available.
Thank you!
Alexis Wilke
Comments
#1
Yep, that's not so ideal. However for me developing rules2 is now the priority, but feel free to improve it. The last way with appending _2 looks imo better, so I'd prefer that one.
#2
Do you mean that you are "dropping" this rules module and creating a brand new one??
I will look into it and see whether that's difficult to do. 8-)
#3
Not really.. ;) The concept and module API stays but I'm revising it's internal code to be more modular, flexible, straight-forward to use - so that powerful extensions like Lists, Loops can be handled seamless.
Read http://more.zites.net/rules/reactive_rules_for_drupal_have_grown_up
#4
Hello Guys,
I am getting this same issue when trying to add a Load Term action, however, I have not used one in my rule. I did use however a "Add a new term to vocabulary" and "Load a vocabulary".
I am attaching the skeleton of my rule. Essentially it is a terms moderation rule, users can suggest a term for a node which gets saved as CCK text field + node reference in a separate content type. When it is set to published by the admin it executes this:
ON
event After updating existing content
IF
condition Updated content is published
DO
action Load a vocabulary
action Add a new term to vocabulary
action Load a referenced node
action Assign a term to content
Any ideas are appreciated:
The problem is the term is not assigned to the referenced node, I believe because I need to load the term, after it gets assigned to the vocabulary.
#5
This is bug report as well as a support request. I'm very confused and I am hoping someone might be able to help me. I'm getting this same error, that the taxonomy term variable already exists, when I try to use the "Load Term" action. Based on this thread and my research it seems that this is a common problem when people are trying to use the "Load Term" action more than once in a single rule. My problem, is that I am getting this error when using the "Load Term" action only once.
I am sensing that the system THINKS that a rule is already loaded. I think this because when I "Add Action", the option to "Assign a term to content" exists. This option usually only exists if a Term has already been loaded.
While editing a rule who's only action were to "load a term", and "assign the term to content", I mistakenly deleted the "load a term" action, leaving only the "assign term to content". I have a strong feeling that this screwed something up in the system and now every new rule I create thinks there is already a term loaded. Does this sound like a possibility? Is there a way to reset the variables that the rule is using so that it knows there is no taxonomy term loaded?
Any help provided would be greatly appreciated! I'm hoping to avoid reinstalling the rule module and recreating all of my rules.
Thanks SO much!
#6
You can manually change the variable name, so there is no bug. But yes, it could be better.
#7
I was having a similar issue. I cloned a rule that had the following conditions and actions:
Conditions:
Created content is blog entry
User has role
Actions:
Load a term
Assign a term to content
In the cloned rule, I went into the "Load a term" action and when I tried to change the term id, got the "variable already exists" error message. To make it work, I went into the "Variable Taxonomy term settings" category at the bottom of the "Load a term" page, and changed "Machine readable variable name" from taxonomy_term to taxonomy_term_2.
Then since there was no way to change what variable the "Assign a term to content" action was looking for, I deleted that action and re-added it.
Seems to work fine now.
Hope this helps get things sorted. Not much help in the whole patch thing yet.
Mickey
#8
Hi, I don't see the "Variable Taxonomy term settings" category at the bottom of the "Load a term" page. The only fields i see on my "Load a Term" page are "Label" and "Vocabulary."
Have I missed something? I know the field you are referring to, i see it in "Load a Vocabulary." But it's seems to be absent from my "Load a Term."
#9
I am experiencing this bug, too. I want to have two rules, each of which applies a term to content after its first being saved, differentiated by user role(s). I can create the first rule without problems but, when I create the second, I cannot get past the 'Load a Term' action: No provision to rename the variable is displayed, just the taxonomy name pulldown. And submitting the form keeps resulting in the 'variable already exists' message discussed herein.
A clarification: I originally had two operational rules that functioned as intended, save that I had chosen the wrong triggering condition, content is going to be saved, rather than after saving new content, with the result that I was getting a taxonomy error after each affected node edit ('Duplicate insert...' db message). So, I deleted my two successful rules and tried to rebuild them with the correct trigger. That's when the above-described problem began.
#10
My work-around was to export all but the rules that were creating the conflict (described in comment #9), then de-install and re-install the rules module. Next I imported all of my just-exported rules. After that, I was able to recreate my rule pair without any problems. This was a nuisance and won't work for everybody but reveals that there is some cruft variable reference occasionally being left somewhere in the DB when a rule is deleted.
#11
Fago,
How do I manually change the variable name?
#12
deaconzero,
At the bottom there is a fieldset, open it and you see the variable name. On creation, you cannot do anything, you have to go edit your first event, then create a new one. The variable name should be changed each time to avoid the problem, but since it's hidden, it's not like you remember each time... 8-)
Hope that helps!
Alexis
#13
Thanks Alexis. What I was doing wrong was trying to create the rule inside of Rule Sets, not Triggered Rules. That option is not there when doing it that way. Once I tried to create it inside of Triggered Rules it was quite obvious. Thanks!
- Nick