I've exported rules using Features and when I change some minor things such as weight, or values, the rules are not being reverted by feature-revert.

$ drush -y fr my_rules
Current state already matches defaults, aborting. 

I've reported that bug against the Features (#2701957: Rules deployment breaks, due to overridden rules not recognized ), however I think this is the problem with Rules, since it's sending the invalid syntax of the rules to the Features.

Basically on feature revert the module is returning the rule in the following format:

  'my_rules_apply_skip_permit_dates' => { "my_rules_apply_skip_permit_dates" : {
      "LABEL" : "Apply for skip permit - dates",
      "PLUGIN" : "reaction rule",
      "OWNER" : "rules",
      "REQUIRES" : [ "my_entityform_rules", "rules_forms" ],
      "ON" : { "rules_forms_apply_skip_permit_entityform_edit_form_form_built" : [] },
      "IF" : [
        { "my_entityform_element_compare_duration_value" : {
            "form" : [ "form" ],
            "form_state" : [ "form_state" ],
            "element" : "date_combo:field_date1:und:0",
            "element_2" : "date_combo:field_date_calendar:und:0",
            "use_today" : "0",
            "type" : "d",
            "op" : "lt",
            "value" : "0"
          }
        }
      ],
      "DO" : []
    }
  },

however Feature's sanitization function (_features_sanitize) which is called from features_get_signature() expect this to be in PHP format (array format), so it doesn't understand it and converts the code into:

    'my_rules_apply_skip_permit_dates' => array(
    'dependencies' => array(
      0 => 'my_entityform_rules',
      1 => 'rules_forms',
    ),
    'label' => 'Apply for skip permit - dates',
    'name' => 'my_rules_apply_skip_permit_dates',
    'owner' => 'rules',
  ),

by removing all the important details such as values, weights, conditions, etc. I think Rules should provide the valid exportable PHP object, unless the fix should be done in _features_sanitize().

Comments

kenorb created an issue. See original summary.

clemens.tolboom’s picture

Thanks for reporting this. I found sandbox CTools Export code - diff [edit] https://www.drupal.org/sandbox/roderik/2409467 [/edit] which shows 5 out of 6 empty diff in my situation and helped me to fix/revert my 6th rules component.

As that module is called CTools guess we need to report at that project.

kenorb’s picture

Sounds interesting. Could you re-post the link to the sandbox, please?

clemens.tolboom’s picture

geek-merlin’s picture

Status: Active » Closed (duplicate)

great thanks for posting this! but please don't double-post for different versions. let's close this and set verstion to dev on #2701957: Rules deployment breaks, due to overridden rules not recognized