I have a custom module that only declares a default rule through hook_default_rules_configuration. For some reason at some point, that I haven't determined yet, all of the blocks are unassigned. I have narrowed it down to this function, if I comment it out it the blocks never do this, but if I let the function run it happens after a few hours of letting the site sit and coming back to it.

Here is my module.rules_defaults.inc file:

<?php
function module_default_rules_configuration() {
  $config = array();
  $rules_path = drupal_get_path('module', 'module') . '/rules';
  $files = file_scan_directory($rules_path, '/\.rule$/');
  foreach ($files as $filepath => $file) {
    require $filepath;
    if (isset($rule)) {
      $config['module_' . $file->name] = rules_import($rule);
    }
  }
  return $config;
}

And here is my rule_name.rule located in module/rules:

<?php
/**
* Rule exported to code: email_default.
*/
$rule =
  '{ "email_default" : {
    "LABEL" : "Module OG Invite Email",
    "PLUGIN" : "rule",
    "REQUIRES" : [ "php", "mimemail" ],
    "USES VARIABLES" : {
      "user_module_og_invite" : { "label" : "User email sends to", "type" : "user" },
      "user_password_module_og_invite" : { "label" : "User password", "type" : "text" },
      "group_organization_entity" : { "label" : "Group organization", "type" : "node" },
      "group_inviting_user" : { "label" : "Group inviting user", "type" : "text" }
    },
    "DO" : [
      { "mimemail" : {
          "to" : "\u003C?php echo $user_module_og_invite-\u003Email; ?\u003E",
          "subject" : "You\u0027ve been invited to Site",
          "body" : "\u003C?php global $base_url; ?\u003E\r\n\u003Ch1 style=\u0022color: #F16653; font-size: 28px; line-height: 30px; font-weight: normal; margin-top: 0px; margin-bottom: 25px;\u0022\u003EYou\u2019ve been invited to \u003Ca href=\u0022mailto:\u003C?php echo $group_inviting_user; ?\u003E\u0022 style=\u0022color: #F16653!important; text-decoration: none!important;\u0022\u003E\u003C?php echo $group_inviting_user; ?\u003E\u003C\/a\u003E\u2019s Site account for \u003C?php echo $group_organization_entity-\u003Etitle; ?\u003E.\u003C\/h1\u003E\r\n\u003Cp\u003EPlease use the login information below to get started. We recommend that after logging in for the first time you change your password.\u003C\/p\u003E\r\n\u003Cp\u003E\r\nLogin: \u003C?php echo $user_module_og_invite-\u003Email; ?\u003E\r\n\u003Cbr\/\u003E\r\nPassword: \u003C?php echo $user_password_module_og_invite; ?\u003E (we recommend changing upon login)\r\n\u003C\/p\u003E\r\n\u003Ctable\u003E\r\n\u003Ctr\u003E\r\n\u003Ctd align=\u0022center\u0022 valign=\u0022middle\u0022 style=\u0022padding-top: 30px;\u0022\u003E\r\n\u003Ca href=\u0022\u003C?php echo $base_url; ?\u003E\/user\/login\u0022 target=\u0022_blank\u0022 style=\u0022font-size: 22px; color: #F16653; text-decoration: none;\u0022\u003E\u003Cimg src=\u0022\u003C?php echo $base_url; ?\u003E\/sites\/all\/themes\/omega\/theme\/images\/email\/email-click-to-login.gif\u0022 alt=\u0022Click Here to Login\u0022 \/\u003E\u003C\/a\u003E\r\n\u003C\/td\u003E\r\n\u003C\/tr\u003E\r\n\u003C\/table\u003E"
        }
      }
    ]
  }
}';
?>

Comments

TR’s picture

Category: Bug report » Support request
Status: Active » Postponed (maintainer needs more info)
Issue tags: -rules, -blocks

Is this still a problem?

I'm not sure what you mean by "all blocks lose assignment".

Can you simplify this rule and still see the same problem? For example, use the core Rule action "Send mail" instead of using MimeMail. Also, don't set all those variables - if you can simplify to remove the dependency on OG that would be helpful.

Also, this is a rules component - does the component show up properly in the Rules UI when you run your code? The component will not actually do anything unless you trigger it - what does your reaction rule look like, what event are you triggering on? Or are you invoking the component programmatically?

There's really not enough information here to reproduce the problem, and by requiring a fully-functional OG setup you're asking for someone to do a LOT of work to try to help you out here. Please simplify things and reduce this to the simplest case that causes the problem.

TR’s picture

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

No further information provided.