I got this question when looking at the code while working on #2133189: Add a new logical operator: NOT:

At the moment, you are grouping the conditions in an 'AND' and an 'OR' group. That is, if you have:

AND  condition 1
OR   condition 2
AND  condition 3
OR   condition 4

...your rule comes out as

line-item condition
AND
  condition 1
  condition 3
OR
  condition 2
  condition 4

My question is: are there any further plans with this?

I don't have an opinion on whether you should have any plans. But if you want to leave it like this, then:

  • I guess this should be documented a bit (though I don't know how or where exactly)
  • You don't need the 'AND' group. You may as well drop it and get condition 1 & 3 on the same height as the line-item condition & OR-group. It doesn't matter in practice... but IMHO it looks less confusing if the 'AND' group wasn't there. And now I've messed the code anyway... you can assign this ticket to me to scrap it.

Comments

jkuma’s picture

Status: Active » Needs work

Hello Roderick,

Yes, you are right, the logical operators and the way inline conditions handles them should be properly documented. From my perspective, I can append some explanations to the phpDoc of inline_conditions_build() function.

As you said, the rule's logical operators comes out as

line-item condition
AND
  condition 1
  condition 3
OR
  condition 2
  condition 4

I think this is the default implementation with rules, but maybe there is a better solution. Feel free to work on it if you wan to. Thanks anyway for raising up this to me.

joelpittet’s picture

Component: Code » Documentation
Status: Needs work » Active

"Needs work" is usually for a patch that needs fixing. https://www.drupal.org/node/156119#needs-work

Also changing this to documentation as mentioned by @goldorak