I thought this was related to another issue but have discovered this bug in production on a site where the rule scheduling was working perfectly before. The site is generating this error on Cron:

Call to a member function restoreBlocks() on a non-object in /var/www/drupal7/sites/all/modules/rules/rules_scheduler/rules_scheduler.module on line 62

It looks that the RulesState object is not being serialized correctly. It looks like this:-

I had a look around to see if there were any PHP serialisation issues around, but I couldn't find anything obvious. We're on PHP 5.3.10


maikeru’s picture

I think this is sort of related to the conversation here:

I'm assuming the TEXT database column needs to change to a BLOB, as Postgres doesn't seem to like NULL values.

[EDIT] Changing the db column to a blob has made it so it actually saves the serialized value (so it looks like O:10:"RulesState":3:{s:7:"\000*\000info"......), but then I still seem to get issues when unserializing.

[EDIT2] Actually, it did work, just all the old rules were queued up, so once I emptied that table the rules have fired correctly.

Richard Banks’s picture

Version: 7.x-2.3 » 7.x-2.5

I can also confirm that switching the data column type from text to bytea (blob) fixes the problem. Also it appears that using blob is the standard convention when working with serialised data.

I had an additional issue with broken entries stuck in the queue which caused errors while running cron.

Tested against PHP 5.4 / PgSQL 9.3 / Rules 7.x-2.5

fago’s picture

Title: RulesState not serializing properly » RulesState not serializing properly due to text column

Sounds reasonable, patch welcome!