The Rules Scheduler breaks on cron with the following error:

PHP Fatal error:  Call to a member function restoreBlocks() on a non-object in /sites/all/modules/rules/rules_scheduler/includes/rules_scheduler.handler.inc on line 31

Fatal error: Call to a member function restoreBlocks() on a non-object in /sites/all/modules/rules/rules_scheduler/includes/rules_scheduler.handler.inc on line 31
Drush command terminated abnormally due to an unrecoverable error.                                                                [error]
Error: Call to a member function restoreBlocks() on a non-object in
/sites/all/modules/rules/rules_scheduler/includes/rules_scheduler.handler.inc, line 31

It appears that on line 30 the $state variable is not being set:

$state = unserialize($this->task['data']);

These are the contents of $this->task['data'] (from the database 'data' field):

O:10:"RulesState":3:{s:7:"*info";a:2:{s:4:"site";a:8:{s:4:"type";s:4:"site";s:5:"label";s:16:"Site information";s:11:"description";s:48:"Site-wide settings and other global information.";s:19:"property info alter";a:2:{i:0;s:9:"RulesData";i:1;s:15:"addSiteMetadata";}s:13:"property info";a:0:{}s:8:"optional";b:1;s:9:"skip save";b:0;s:7:"handler";b:0;}s:7:"account";a:4:{s:5:"label";s:7:"Account";s:4:"type";s:4:"user";s:9:"skip save";b:0;s:7:"handler";b:0;}}s:9:"variables";a:2:{s:4:"site";O:22:"EntityStructureWrapper":6:{s:15:"*propertyInfo";a:1:{s:10:"properties";a:0:{}}s:22:"*propertyInfoAltered";b:0;s:11:"*langcode";s:3:"und";s:7:"*type";s:4:"site";s:7:"*data";b:0;s:7:"*info";a:9:{s:4:"type";s:4:"site";s:5:"label";s:16:"Site information";s:11:"description";s:48:"Site-wide settings and other global information.";s:19:"property info alter";a:2:{i:0;s:9:"RulesData";i:1;s:15:"addSiteMetadata";}s:13:"property info";a:0:{}s:8:"optional";b:1;s:9:"skip save";b:0;s:8:"langcode";N;s:17:"property defaults";a:0:{}}}s:7:"account";O:19:"EntityDrupalWrapper":5:{s:5:"*id";s:3:"198";s:9:"*bundle";s:4:"user";s:11:"*langcode";s:3:"und";s:7:"*type";s:4:"user";s:7:"*info";a:5:{s:4:"type";s:4:"user";s:5:"label";s:15:"registered user";s:9:"skip save";b:0;s:8:"langcode";N;s:17:"property defaults";a:0:{}}}}s:19:"*currentlyBlocked";a:1:{i:102;b:1;}}

When run it via unserialize directly, I get this error:

Notice: unserialize(): Error at offset 33 of 1345 bytes in [...][...] on line 2
false

PHP:

var_export( unserialize( O:10:"RulesState":3:{s:7:"*info";a:2:{s:4:"site";a:8:{s:4:"type";s:4:"site";s:5:"label";s:16:"Site information";s:11:"description";s:48:"Site-wide settings and other global information.";s:19:"property info alter";a:2:{i:0;s:9:"RulesData";i:1;s:15:"addSiteMetadata";}s:13:"property info";a:0:{}s:8:"optional";b:1;s:9:"skip save";b:0;s:7:"handler";b:0;}s:7:"account";a:4:{s:5:"label";s:7:"Account";s:4:"type";s:4:"user";s:9:"skip save";b:0;s:7:"handler";b:0;}}s:9:"variables";a:2:{s:4:"site";O:22:"EntityStructureWrapper":6:{s:15:"*propertyInfo";a:1:{s:10:"properties";a:0:{}}s:22:"*propertyInfoAltered";b:0;s:11:"*langcode";s:3:"und";s:7:"*type";s:4:"site";s:7:"*data";b:0;s:7:"*info";a:9:{s:4:"type";s:4:"site";s:5:"label";s:16:"Site information";s:11:"description";s:48:"Site-wide settings and other global information.";s:19:"property info alter";a:2:{i:0;s:9:"RulesData";i:1;s:15:"addSiteMetadata";}s:13:"property info";a:0:{}s:8:"optional";b:1;s:9:"skip save";b:0;s:8:"langcode";N;s:17:"property defaults";a:0:{}}}s:7:"account";O:19:"EntityDrupalWrapper":5:{s:5:"*id";s:3:"198";s:9:"*bundle";s:4:"user";s:11:"*langcode";s:3:"und";s:7:"*type";s:4:"user";s:7:"*info";a:5:{s:4:"type";s:4:"user";s:5:"label";s:15:"registered user";s:9:"skip save";b:0;s:8:"langcode";N;s:17:"property defaults";a:0:{}}}}s:19:"*currentlyBlocked";a:1:{i:102;b:1;}} ) );

Note this part:

s:7:"*info"

Shouldn't the 7 be a 5 for proper serialization?

Perhaps the serialization isn't working correctly when the component is first entered? I just tried another simpler component (send an email), and the error is the same.

Any ideas?

In case it's helpful, this is my workflow: A rule is triggered when user is created, triggering a bunch of operations that work fine. At the end, a rules schedule component is triggered to fire off 10 days before an expiration date (set via a profile date field) to send an email notification. Pretty simple stuff.

Comments

mr.andrey’s picture

Title: Fatal error: Call to a member function restoreBlocks() on a non-object in modules/rules/rules_scheduler/includes/rules_scheduler.handler.inc on line 32 » Fatal error: Call to a member function restoreBlocks() on a non-object in modules/rules/rules_scheduler/includes/rules_scheduler.handler.inc on line 31
Issue summary: View changes
mr.andrey’s picture

Issue summary: View changes
mr.andrey’s picture

I notice that all the "*" characters have extra 2 characters added to the index. Could it be that they are escaped by quotes when entered, and the index is calculated to compensate for that? Hence the discrepancy?

When data is entered: \*\info
Then in MySQL the slashes are actually erased: *info
But the index stays at 7

mr.andrey’s picture

Status: Active » Closed (works as designed)

My issue seemed to stem from me altering the evaluation date via phpMyAdmin in order to test the rule. Apparently that breaks rules.

ferrangil’s picture

@mr.andrey could you give some more feedback on what you did?
We are seeing the same error and we also did modified some dates from the rules_scheduler tables, both via phpMyAdmin and programatically (when buying a renew product let's say).
I cannot remove all scheduler rules I have (some thousands) as each one will remove a role to an specific user at some point in the future... (and this action works, although on each cron I have the fatal error described here).