hi,
I have set up a rule with some actions and 4 conditional blocks,
the rule should take information from webform submission and create entities base on the data.
first problem - if statement always evaluates as false, the same variable I use successfully in a "show message on site" appears empty in the if statement.

even more alarming is the fact that when you edit that if all conditional blocks break and the following blocks are deleted.
(if I edit the first if I loose the other 3 conditional blocks).

thanks in advanced for your help.

Comments

zhangtaihao’s picture

Could you post an export of the rule?

zhangtaihao’s picture

Status: Active » Postponed (maintainer needs more info)
ciocco’s picture

I'm experiencing this issue. Here is an export of the rule PRIOR to editing:

{ "rules_esign_date_lock_signature" : {
    "LABEL" : "eSign Date \u0026 Lock Signature",
    "PLUGIN" : "reaction rule",
    "TAGS" : [ "eSign" ],
    "REQUIRES" : [ "webform_rules", "php", "rules", "rules_conditional" ],
    "ON" : [ "webform_rules_submit" ],
    "IF" : [
      { "webform_has_id" : {
          "form_id" : [ "form_id" ],
          "selected_webform" : { "value" : {
              "webform-client-form-2836" : "webform-client-form-2836",
              "webform-client-form-3624" : "webform-client-form-3624"
            }
          }
        }
      },
      { "AND" : [] },
      { "php_eval" : { "code" : "$usrid = $user-\u003Euid;\r\n$eSignNID = $data[\u0022components\u0022][\u0022esign_doc_reference\u0022][\u0022value\u0022][0];\r\n\r\n$sql = \u0022SELECT field_esign_faculty_target_id AS uid FROM {field_revision_field_esign_faculty} WHERE entity_id= \u0027$eSignNID\u0027\u0022;\r\n\r\n$dbreslt= db_query($sql);\r\n$row = $dbreslt-\u003EfetchObject();\r\n\r\n$userallowed = FALSE;\r\nif ($row-\u003Euid == $usrid) {\r\n  $userallowed = TRUE;\r\n}\r\nreturn $userallowed;" } }
    ],
    "DO" : [
      { "CONDITIONAL" : [
          {
            "IF" : { "php_eval" : { "code" : "$eSignNID = $data[\u0022components\u0022][\u0022esign_doc_reference\u0022][\u0022value\u0022][0];\r\n$n = node_load($eSignNID );\r\n\r\n\/\/Set Agreement to VALID\r\n$agr_isValid = TRUE;\r\n\r\n$dt_expr = $n-\u003Efield_esign_expire;\r\nif(!empty($dt_expr)) {\r\n  \/\/An expiration date exists, check it\r\n  $expire_dt = strtotime($dt_expr[\u0022und\u0022][0][\u0022value\u0022]);\r\n  \r\n  \/\/Compare NOW to expiration Date  \r\n  $now= strtotime(date(\u0022Y-m-d G:i:s\u0022));\r\n\r\n  if ($expiration_date \u003C $now) { \r\n    $agr_isValid = FALSE:\r\n  }\r\n}\r\n\r\nreturn $agr_isValid;" } },
            "DO" : [
              { "php_eval" : { "code" : "$eSignNID = $data[\u0022components\u0022][\u0022esign_doc_reference\u0022][\u0022value\u0022][0];\r\n$iagree = $data[\u0022components\u0022][\u0022i_agree\u0022][\u0022value\u0022][0];\r\n\r\n$n = node_load($eSignNID );\r\n$tmpdt_signed = $n-\u003Efield_esign_dt_signed;\r\n$tmpi_agree = $n-\u003Efield_esign_iagree;\r\n$tmpbody = $n-\u003Efield_body;\r\n\r\n\/\/Update Date Signed\r\n$now = date(\u0027Y-m-d G:i:s\u0027);\r\n$tmpdt_signed[\u0022und\u0022][0][\u0022value\u0022] = $now;\r\n$n-\u003Efield_esign_dt_signed = $tmpdt_signed;\r\n\r\n\/\/Update I Agree Field\r\n$tmpi_agree[\u0022und\u0022][0][\u0022value\u0022] = $iagree;\r\n$n-\u003Efield_esign_iagree = $tmpi_agree;\r\n\r\n\/\/Update Body Field\r\n$now = date(\u0027m\/d\/Y g:i:s A\u0027);\r\n$tmpbody[\u0022und\u0022][0][\u0022value\u0022] = \u0022The an electronic signature was last recorded on \u0022 . $now;\r\n$n-\u003Efield_body = $tmpbody;\r\n\r\n$n-\u003Erevision = 1; \/\/ Create new revision\r\n$n-\u003Elog = \u0022Updated via user e-Signature on \u0022 . $now; \/\/ Log message\r\n\r\n\/\/Save Changes \u0026 Make Revision\r\nnode_save($n);" } },
              { "drupal_message" : { "message" : "Your eSignature submission has been recorded.  Details for your eSignature to this agreement can be viewed under the \u003Cem\u003EeSignature Record\u003C\/em\u003E section for this agreement on the My eSignatures page." } }
            ]
          },
          { "ELSE" : [
              { "drupal_message" : { "message" : "This agreement has expired.  Please review the expiration date.  Contact the CGCE Director of Online Services for further assistance." } }
            ]
          }
        ]
      }
    ]
  }
}

Once I clicked "edit" for the If statement in the conditional, this reverted the rule to a previous state, several iterations back, infact. Here is the export of the RULE after having clicked edit and the system reverted the rule to a previous state:

{ "rules_esign_date_lock_signature" : {
    "LABEL" : "eSign Date \u0026 Lock Signature",
    "PLUGIN" : "reaction rule",
    "TAGS" : [ "eSign" ],
    "REQUIRES" : [ "webform_rules", "php", "rules", "rules_conditional", "cache_actions" ],
    "ON" : [ "webform_rules_submit" ],
    "IF" : [
      { "webform_has_id" : {
          "form_id" : [ "form_id" ],
          "selected_webform" : { "value" : {
              "webform-client-form-2836" : "webform-client-form-2836",
              "webform-client-form-3624" : "webform-client-form-3624"
            }
          }
        }
      },
      { "AND" : [] },
      { "php_eval" : { "code" : "$usrid = $user-\u003Euid;\r\n$eSignNID = $data[\u0022components\u0022][\u0022esign_doc_reference\u0022][\u0022value\u0022][0];\r\n\r\n$sql = \u0022SELECT field_esign_faculty_target_id AS uid FROM {field_revision_field_esign_faculty} WHERE entity_id= \u0027$eSignNID\u0027\u0022;\r\n\r\n$dbreslt= db_query($sql);\r\n$row = $dbreslt-\u003EfetchObject();\r\n\r\n$userallowed = FALSE;\r\nif ($row-\u003Euid == $usrid) {\r\n  $userallowed = TRUE;\r\n}\r\nreturn $userallowed;" } }
    ],
    "DO" : [
      { "CONDITIONAL" : [
          {
            "IF" : { "php_eval" : { "code" : "$eSignNID = $data[\u0022components\u0022][\u0022esign_doc_reference\u0022][\u0022value\u0022][0];\r\n$n = node_load($eSignNID );\r\n\r\n\/\/Set Agreement to VALID\r\n$agr_isValid = TRUE;\r\n\r\n$dt_expr = $n-\u003Efield_esign_expire;\r\nif(!empty($dt_expr)) {\r\n  \/\/An expiration date exists, check it\r\n  $expire_dt = strtotime($dt_expr[\u0022und\u0022][0][\u0022value\u0022]);\r\n  \r\n  \/\/Compare NOW to expiration Date  \r\n  $now= strtotime(date(\u0022Y-m-d G:i:s\u0022));\r\n\r\n  if ($expiration_date \u003C $now) { \r\n    $agr_isValid = FALSE:\r\n  }\r\n}\r\n\r\nreturn $agr_isValid;" } },
            "DO" : [
              { "drupal_message" : { "message" : "Contract is still valid" } },
              { "CONDITIONAL" : [] }
            ]
          }
        ]
      },
      { "php_eval" : { "code" : "$eSignNID = $data[\u0022components\u0022][\u0022esign_doc_reference\u0022][\u0022value\u0022][0];\r\n$iagree = $data[\u0022components\u0022][\u0022i_agree\u0022][\u0022value\u0022][0];\r\n\r\n$n = node_load($eSignNID );\r\n$tmpdt_signed = $n-\u003Efield_esign_dt_signed;\r\n$tmpi_agree = $n-\u003Efield_esign_iagree;\r\n$tmpbody = $n-\u003Efield_body;\r\n\r\n\/\/Update Date Signed\r\n$now = date(\u0027Y-m-d G:i:s\u0027);\r\n$tmpdt_signed[\u0022und\u0022][0][\u0022value\u0022] = $now;\r\n$n-\u003Efield_esign_dt_signed = $tmpdt_signed;\r\n\r\n\/\/Update I Agree Field\r\n$tmpi_agree[\u0022und\u0022][0][\u0022value\u0022] = $iagree;\r\n$n-\u003Efield_esign_iagree = $tmpi_agree;\r\n\r\n\/\/Update Body Field\r\n$now = date(\u0027m\/d\/Y g:i:s A\u0027);\r\n$tmpbody[\u0022und\u0022][0][\u0022value\u0022] = \u0022The an electronic signature was last recorded on \u0022 . $now;\r\n$n-\u003Efield_body = $tmpbody;\r\n\r\n$n-\u003Erevision = 1; \/\/ Create new revision\r\n$n-\u003Elog = \u0022Updated via user e-Signature on \u0022 . $now; \/\/ Log message\r\n\r\n\/\/Save Changes \u0026 Make Revision\r\nnode_save($n);" } },
      { "cache_actions_action_clear_cache" : { "tables" : { "value" : {
              "cache" : "cache",
              "cache_block" : "cache_block",
              "cache_filter" : "cache_filter",
              "cache_page" : "cache_page",
              "cache_field" : "cache_field",
              "cache_image" : "cache_image",
              "cache_token" : "cache_token",
              "cache_views" : "cache_views",
              "cache_views_data" : "cache_views_data",
              "cache_rules" : "cache_rules"
            }
          }
        }
      },
      { "drupal_message" : { "message" : "\u003C?\r\n$eSignNID = $data[\u0022components\u0022][\u0022esign_doc_reference\u0022][\u0022value\u0022][0];\r\n$n = node_load($eSignNID );\r\n\r\n\/\/Set Agreement to VALID\r\n$agr_isValid = TRUE;\r\n\r\n$dt_expr = $n-\u003Efield_esign_expire;\r\nif(!empty($dt_expr)) {\r\n  echo \u0022DT expire is NOT NULL\u003Cbr\u003E\u0022;\r\n  \/\/An expiration date exists, check it\r\n  $expire_dt = strtotime($dt_expr[\u0022und\u0022][0][\u0022value\u0022]);\r\n  \r\n  \/\/Compare NOW to expiration Date  \r\n  $now= strtotime(date(\u0022Y-m-d G:i:s\u0022));\r\n\r\n  if ($expiration_date \u003C $now) { \r\n    $agr_isValid = FASLE:\r\n  }\r\n} else {\r\n echo \u0022DT expire is NULL\u003Cbr\u003E\u0022;\r\n}\r\n\r\n?\u003E\r\n\r\nYour eSignature submission has been recorded.  Details for your eSignature to this agreement can be viewed under the \u003Cem\u003EeSignature Record\u003C\/em\u003E section for this agreement on the My eSignatures page." } }
    ]
  }
}
olegvo’s picture

I have the same problem. I lost several conditional rules after editing. I made the rule yesterday and tested it, everything worked well. Today I found that some "if" actions were lost. Is this problem fixed in dev. version?

zhangtaihao’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

I'm afraid I wasn't able to reproduce the issue. It could be that one of the plugins needed to reset the cache of a parent element, but I could not tell which one.

I will investigate further when I have some time. Meanwhile, perhaps you could try clearing Rules cache before performing actions that you have known to revert to an earlier state.

tuccio’s picture

Priority: Major » Critical
Status: Closed (cannot reproduce) » Active

Hi,

I have been using Conditional Rules for a while and I think it's a great concept and module, but I have also experienced several times the issue of losing changes and having the Rule revert to a much older state. I believe this thread is about this problem.

I am not sure which changes cause the issue (although I think that pulling already existing items out of and into conditions has to do with this), but the issue in my case has happened after several "Flush all caches actions", so the old data seems to be stored in a location that is not affected by the Flush all caches command.

I am also escalating the priority to critical because of the loss of time and effort caused by this issue since it may happen at any time and because the module allows the creation of rules of unlimited complexity, then the loss may as well be unlimited.

zhangtaihao’s picture

I have actually now run into the issue a couple of times. My colleague has run into it more.

It would seem that, if any part of Rules fails an integrity check (i.e. shows red text to indicate error), Rules caches the error state until some change triggers it to revert to the error state (or just before; I couldn't quite tell).

We have now taken care to not cause any integrity errors, e.g. usually caused by renaming variables and thus breaking action settings. We now no longer run into this issue.

Could you try that approach and determine if it's still an issue?

tuccio’s picture

Priority: Critical » Major

Thank you for your help. I'll try to avoid integrity errors and see if this fixes the problem.

MrFusion’s picture

Issue summary: View changes

Same problem. But in my case it's almost impossible to create needed rules without fixing this bug because of their complexity (100, 200+ actions in one rule). I had even more weired case. In the evening I finished this rule, saved it and checked. Everything was there. In the morning some actions disappeared. Hope for fixing this bug soon!

Joel MMCC’s picture

@MrFusion (#9):

I had even more weird case. In the evening I finished this rule, saved it and checked. Everything was there. In the morning some actions disappeared. Hope for fixing this bug soon!

So, it may be happening during a cron run?

sprucemoose’s picture

I have just come across this thread after suffering the same problem. I have witnessed the same weird behavior as MrFusion (#9) with rules reverting to an earlier state without being touched through the UI.

delacosta456’s picture

hi
i have also faced this situation and sometime this looks to happen when the list of actions and conditions is long ... Also what i had notice (I AM not SURE) but it's looks like the module Rules Filter doesn't play well with Rules conditional .. If somebody else has it install please confirm.

Thanks