I've got a problem with a rule that fires when I think it shouldn't.


My Article content type uses the Node Expire and Node Expire Extras modules to control automatic Article expiration. I have the following “expiration” rule defined:

{ "rules_expired_content" : {
    "LABEL" : "Expired Content",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "node_expire" ],
    "ON" : { "node_expired" : [] },
    "DO" : [ { "node_unpublish" : { "node" : [ "node" ] } } ]

The rule sets the Article to “unpublished”.

My users asked that I provide a way to selectively control if an email is sent when an article is updated. To that end, I added a field (radio button) to the Article content type called “Send email” (field_send_email). The field defaults to “Yes”. I wrote two rules: when content is saved and when content is updated. The rule for saving content seems to work flawlessly. Here's the rule for updating the content:

{ "rules_updated_article_email_notification_cloned_" : {
    "LABEL" : "Updated Article Email Notification",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "TAGS" : [ "Email" ],
    "REQUIRES" : [ "rules", "node_expire", "php", "mimemail" ],
    "ON" : { "node_update--article" : { "bundle" : "article" } },
    "IF" : [
      { "data_is" : { "data" : [ "node:field-send-email" ], "value" : "1" } },
      { "AND" : [ { "NOT node_expire_rules_expired_check" : { "node" : [ "node" ] } } ] }
    "DO" : [
      { "mimemail_to_users_of_role" : {
          "key" : "xxxxxxxxxxxxxxxxxx",
          "roles" : { "value" : { "4" : "4" } },
          "active" : "1",
          "from_mail" : [ "node:author:mail" ],
          "subject" : "An article has been updated: [node:title]",
          "body" : "[node:body]",
          "attachments" : "\u003C?php\r\nforeach($node-\u003Efield_file_attachments[\u0027und\u0027] as $file) {\r\n  echo  drupal_realpath(file_load($file[\u0027fid\u0027])-\u003Euri);\r\necho (\u0022\\n\u0022);}\r\n?\u003E",
          "language_user" : "1",
          "language" : [ "" ]


When cron runs, it fires the rule that detects that an Article has expired. That changes the state of the Article to “unpublished”. Changing the state forces the above updated Article rule to fire. Today, December 31st, a series of emails was sent out unexpectedly. I know it has something to do with the Updated Article rule, but, I am at a loss to pinpoint the cause. I checked the system log and noticed the following line that looked suspicious:

Notice: Undefined property: stdClass::$expired in node_expire_rules_expired_check() (line 98 of /XXXX/XXXX/public_html/XXXXX/sites/all/modules/node_expire/node_expire.rules.inc).

I did not find any reported problems with the Node expire module and the above message.

I also ran some localhost tests and the code appeared to run correctly although I'm not sure I'm simulating an expired node correctly by forcing it from Cron.

I've turned on Rules debug so that it will show in the system log for future issues with Articles. However, if anyone can shed some light on this, I'd greatly appreciate it.

UPDATE: I have since found that this bug is inconsistent. I had one article that was unpublished and had the problem, and, another that did not. The only difference seems to be that the one with the problem was also originally promoted to the front page.

UPDATE 2: I'm not getting any response on the Drupal Node Expire page. If anyone knows of an alternative mechanism to implement Node expiration without using the above mentioned modules, I'd love to hear.

  • What are the criteria you have in place for a node to be considered as "expired"? And what kind of patterns did you see in all those nodes for which such eMail (as in your "series of eMails") were created? Jan 1, 2017 at 10:06
  • @Pierre.Vriens Each Article was created with a node expiration of December 31st. Additionally, each Article had the "Send email" flag set to true. My assumption was that since the node had "expired", the check in the rule would not send the email.
    – rrirower
    Jan 1, 2017 at 16:23
  • You didn't reply yet to y first question, i.e. ***What are the criteria you have in place for a node to be considered as "expired". Is that like an extra date field in a node, which include the expiration date? If not what is it then? Extra question: are you using the 7.1 or 7.2 version of the module (looking at your error I'm about sure it is 7.1, but I want to be 100% sure). Jan 29, 2017 at 17:07
  • @Pierre.Vriens Sorry, thought I had explained that. Since I use the Node Expire module, each article has an "expiration date" that the user enters when the article is posted. The "expiration date" field is provided by the module. The date is later compared when Cron runs to see if the article has "expired" Let me know if you need more info.
    – rrirower
    Jan 29, 2017 at 17:13
  • aha, that's what I wanted to be sure of. To be honest, from the various details in your question, I do believe you've run in some bug that hasn't been reported yet. However, if I was in your shoes, I'd try to remove the need for those 2 modules entirely, simply by (a) creating my own field (with similar purpose) in that content type and (b) use the Rules Scheduler to have a (new) custom rule to "schedule" the unpublish of the node. If you want to know more about that, I suggest you add something to your question like "Or is there an alternative to implement the equivalent of these modules". Jan 29, 2017 at 17:20

1 Answer 1


Your problem is node_unpublish will be saving the node, triggering the second rule on node_update--article thereby actioning mimemail_to_users_of_role

Looks like you'll need to add a condition to make sure the email should be sent. For example, you could check the updated node is not being set to "unpublished"

"IF" : [ { "data_is" : { "data" : [ "node:status" ], "value" : "1" } } ],
  • Can you explain why the rule condition I have now does not work? Seems like it should since it's based on the 'expired' field in the node.
    – rrirower
    Feb 2, 2017 at 20:26
  • @rrirower because the rule on node_expired will unpublish the node, triggering the reaction rule on node_update--article separately from the expired node check. Feb 3, 2017 at 0:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.