Closed (fixed)
Project:
Rules
Version:
6.x-1.x-dev
Component:
Rules Engine
Priority:
Major
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
29 May 2009 at 04:34 UTC
Updated:
3 Jan 2014 at 00:29 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
i.chris.jacob commentedI've got my site back online by commenting out the contents of function "rules_action_drupal_goto" from system.rules.inc
I've now hit a new issue... I previously deleted the rule from the rules_rules table... so how do I now go about cleanly removing the rest of the rule without it being shown in my list of rules? (i.e. the redirect still exists without the Rule in the database - so I assume Rules modules does come cleaning-up on deletion of a rule; which I bypassed by stupidly deleting the record from the rules_rules table).
Original Rule:
Event: User is going to view a page
Condition: Path has alias(es)
- Existing system path: "events"
Action: System > Page Redirect
- To: "/calendar"
I then deleted the Condition (as it seemed not to work and I wanted to try "URL Alias Exists" instead)... the result of pressing the Delete button what a redirect to mysite//calendar (double // as my TO: action was /calendar instead of just calendar [no slash]).
I can't use rules_action_drupal_goto until my old redirect is cleaned up :-(
Your help is most welcome.
Comment #2
i.chris.jacob commentedI resolved my support issue (not totally sure how). Re assigning issue as a Bug Report - and critical because this can bring down an entire site.
If you stumble upon this issue here's my suggestions:
1. comment out the content of the function rules_action_drupal_goto from system.rules.inc
2. go to rules and add back in a Condition to your page redirect rule (or delete the rule altogether)
3. remove your comments from system.rules.inc and upload
4. test to make sure the evil recursive loop has gone away
If you stupidly deleted the Rule from the rules_rules table (like I did) follow steps 1, then try recreating the rule (including the condition) and then Delete the rule (don't know how/why but this seems to have cleaned up the previous rule too - for me anyway). Then follow steps 3 and 4.
Good luck, and I hope this bug gets squished soon.
Comment #3
mitchell commented@i.chris.jacob: I'm glad you were finally able to figure it out.
This seems like an important bug/feature that may end up being rather complex.
Comment #4
amitaibuWith power comes responsibility... You can also delete your whole DB with the execute PHP action. I don't think it's possible to anticipate which rules will cause errors. IMO, this issue should be won't fix.
Comment #5
mitchell commentedI don't think this use case applies to those who would use the PHP action. #323312: Add PHP execution permissions is an issue where we can help prevent undesirable events with the execute PHP action.
There are a wide range of possibilities where normal Rules usage can bring down Drupal. As a general rule of thumb, a proper action at that point would be to deactivate the offending rule and display a message, 'Rules deactivated rule_# because it would cause x, y, or z.'
To do this, we could further integrate rules with itself:
- Event: rule is saved
- Condition: rule is unsafe
- Action: inactivate rule
Thankfully, i.chris.jacob's reported a rule signature that breaks stuff, much like a virus definition. Obviously we can't predict all user behaviors, but we can at least interpret some events and act on them, so as to avoid giving users "the dangerous module" :-)
Similarly, in #445084-11: Adjust module weight from 0:
We could further integrate rules with core:
- Event: module is enabled
- Condition: rules's weight is not right
- Action: set module weight.
Comment #6
AlexisWilke commentedJust a thought on this one... It seems that some rules, such as drupal_goto() calls, may need to be turned off if the user is in the admin screen. That, I think, would be enough.
As I have now been playing with the Rules module, I have noticed quite a few side effects with rules calling other rules calling other rules... Here you can easily get recursivity and I don't recall seeing anything that will prevent an infinite loop of the Rules system, although I hope I'm wrong. (i.e. Save User data, generates an update, runs another Rule which Saves a Taxonomy, that wakes up another Rule which happens to be the first rule and that again Saves User data, etc.)
So, what I'm saying is that we should have internal conditions that prevent silly things from happening. In this instance, we could even totally prevent a redirect if there are no conditions since it would make no sense anyway.
Thank you.
Alexis
Update: The recursivity is being checked. I ran into it once and got a message about a loop being broken.
Comment #7
fago>I don't recall seeing anything that will prevent an infinite loop of the Rules system
oh that's in there, else you would run into loops quite fast.
>So, what I'm saying is that we should have internal conditions that prevent silly things from happening. In this instance, we could even totally prevent a redirect if there are no conditions since it would make no sense anyway.
I don't think it's realistic to try to prevent "bad configurations". That's the users responsibility, however the UI should not immediately apply the changes. Thus if you just want to remove the condition to add another one, it shouldn't cause troubles. However, this is quite a major change, that won't happen for rules 1.x any more.
Comment #8
kingkufre commentedthanks
had the same problem and resolved it by following your instructions to the letter.
so did you finally get the rule to work?
You had:
Original Rule:
Event: User is going to view a page
Condition: Path has alias(es)
- Existing system path: "events"
Action: System > Page Redirect
- To: "/calendar"
My question is did you get the rule to work as above? Or what did you use as above is not working for me?
Your help is most welcome!
Comment #9
klausiComment #10
fagoI do think we should just disable redirects for the whole admin area. Also see #732542: system_goto_action breaks core APIs.
Comment #11
fagoWe cannot use hook_admin_paths() as this might contain stuff like node/X/edit too, so I guess best we just disable dangerous actions like the page redirect action for /admin/* ?
Comment #12
AlexisWilke commentedfago,
Couldn't we limit it to admin/rules/* ?
Thank you.
Alexis
Comment #13
fagoThat would work too, but why not to "admin" at all? Are there use-cases where one wants to use rules-driven page redirects in the admin area?
Comment #14
AlexisWilke commentedI guess that if someone needs such a tweak they can always do it in they .htaccess or directly in the code. I do not know of a case myself, although I have a rather heavily transformed version of Drupal since there are many problems that can easily be solved (i.e. missing blocks on 404 pages for instance!)
I guess that a redirect within the admin would mean you want a customer to never go to page A and redirect him/her to page B instead where he/she can do the setup without breaking anything. That probably means you programmed a new page (B) that replaced the old page (A) and thus can do the redirect in software too.
Will see if anyone else comes up with something.
Thank you.
Alexis
Comment #15
fagoWe should include a built-in check for the drupal_goto action, or better for all events firing on rules-admin screens. Thoughts?
Comment #16
fagoadding tag
Comment #17
klausiHere is a patch that just tackles the page redirect action. It works for GET requests when visiting the Rules administration pages, but it does not fully work on form submissions (saving changes of a rules configuration). I guess the form redirects somehow interfere.
Comment #18
fagoIt won't work for POST requests because it doesn't need hook_page_build() to work then. We should throw the warning directly in the action and bail out, then it should work for POST too.
Comment #19
klausiOf course, I was blind. Patch attached.
Comment #20
fagopatch looks good.
Somehow related, should we also add a check for batches as in the proposed core patch?
Comment #21
klausiI think it is enough to protect Rules administration pages, so that people are always able to revert/disable/delete their malicious redirect actions. But otherwise we are not their parents: they can shoot them in the foot, if they want to.
Comment #22
fagoI think it's our job to assist users doing so + we I'd argue no one wants page-directs to happen during batches. Thus, I've added the check too.
I've committed your patch + added the check in a follow-up. thanks.
Comment #23
AlexisWilke commentedIs the patch applicable to 6.x too? If so, should we have it ported there too?
Thank you.
Alexis Wilke
Comment #24
fagoYep, porting this to 6.x is probably a good idea.