Hi, it seems imposible to correctly compare, whether long text and summary field value changed - if the new or old value is empty.

How to replicate: fresh install drupal 7.23, rules 2.5 (same was in rules 2.3), entity api 7.x-1.2, token 7.x-1.5.
Create rule to react to node update, data compare node:body:value doesn't equal node-unchanged:body:value
The rule export is below as rule 1. If the old or new value is empty, folowing error appears in rules debug log and the rule doesn't fire:

Unable to get the data value for the variable or parameter value. Error: Unable to get the data property value as the parent data structure is not set.

I understand, that it might be the problem that it is not possible to get the value of the node body, when it is is empty. So I tried to compare the whole field - and created a rule comparing the whole filed: node:body doesnt equal node-unchanged:body . The rule export is below as rule 2. In this case the rule always fires - regardles of wheter the node body is changed or not - if you change eg. the node title only.

So it's hard to compare if node body changed, including cases from empty to something or vice versa. The only workaround is to make complex condittions - checking if: ((old value is empty) and (new value is not empty)) or ((old value is not empty) and (new value is empty)) or (old value not equals new vaule). The workaround still results in an error, but evaluates as desired.

I searched the issue queue but could not find anything relevant. It seems to me all rather complex, not sure if it's a rules problem, or entity problem, or actually working as designed, so forgive me, if reporting at the wrong place or misunderstanding some concepts.

Rule 1 export

{ "rules_node_body_changed" : {
    "LABEL" : "node body changed",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules" ],
    "ON" : { "node_update" : [] },
    "IF" : [
      { "NOT data_is" : {
          "data" : [ "node:body:value" ],
          "value" : [ "node-unchanged:body:value" ]
        }
      }
    ],
    "DO" : [ { "drupal_message" : { "message" : "Fired" } } ]
  }
}

Rule 2 export

{ "rules_node_body_changed" : {
    "LABEL" : "node body changed",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules" ],
    "ON" : { "node_update" : [] },
    "IF" : [
      { "NOT data_is" : { "data" : [ "node:body" ], "value" : [ "node-unchanged:body" ] } }
    ],
    "DO" : [ { "drupal_message" : { "message" : "Fired" } } ]
  }
}

Comments

fago’s picture

Title:Cannot correctly compare whether Long text and summary field value changed» Simplify comparing whether Long text and summary field value changed
Category:bug» feature

Yeah, I don't think there is a bug though. You might have to manually check the case of the whole field being empty before comparing things.