Naming Things is Hard

Today I Learned

...about the alternate-universe logic of Conditions in Rules in Drupal

So, okay, this is kind of dumb, and it's probably covered somewhere else, better than this, but it took me more than a minute to figure it out, after digging through issue queues, so I don't want to lose it, so here we go:

I'm setting up some Rules in Drupal 7, and I'm trying to lay out logic that looks like this in my condition set:

(A && B) || (C && D)

So it's something like, "If field A is not empty, and it has this value, OR, if field C is not empty, and it has this value, fire off the event."

Except the indentation that made sense to me didn't make sense to Drupal:

A
|_ AND
   |_ B
   |_ OR
      |_ C
         |_ AND
            |_ D

Or something like that; I lost track of what I tried. The gist of it being, I was thinking of the AND and OR indentations as a tree that Drupal would walk, branching down until it got enough truthness or falseness to quit walking or fire the event.

In reality, the ANDs and ORs are more like group headers; they implicitly AND and OR everything within them. So it's like rewriting the logic way up top to look more like this:

|| (&& (A B)) (&& (C D))

Which leads to indentation in the Rules condition set that looks like this:

OR
|_ AND
   |_ A
   |_ B
|_ AND
   |_ C
   |_ D

Which, well. Okay! Now I know this.

tags

Home & About & Micro.blog & Feed (Atom)