0

we know that via hook_* we can make everything, but my question is about the use of Rules vs hook_. At high level performance programming hook_ is better that rules, but if we consider a normal level performance ?

In a site where you have installed rules (like a commerce) is better to use hook_* or I can create a rule that exec an PHP function? In the first way (hook_*) I need to remember in which module an FooBar thing happen (say does something before node's saving, hook_node_presave) but I have max performance; second way is via Rules module where I have all rules in one path and I can crete a Rules that is "called" when "condition" "before saving new node of node type XYZ" appair.

Which is better in a normal site ? Or in a site more than normal ?

M.

PS: sorry for my bad english.

3

In practice, it is far easier to debug a hook than a rule that includes a PHP function. So, not only are hooks faster, they are easier to maintain and less likely to present security risks.

You do not need to remember "in which module foo happens" if you put all your hooks in a single custom module for the site. Unless you have an extremely large number of tweaks, using a single module (and version controlling it!) is probably the easiest way to do this.

Regardless of the size of the site, if you want to write custom PHP, you should use a custom module, not rules.

  • 1
    What, no attack on the PHP filter in general? I'm disappointed...;) – Clive Jan 24 '13 at 15:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.