What I have tried:

  1. Clear Cache.
  2. Disabled module and enabled it.
  3. Try with registry_rebuild, module_missing_message_fixer, variablecheck modules.

Still getting the below error when I try to run update.php.

Notice: unserialize(): Error at offset 668 of 1298 bytes in \sites\all\modules\entity\includes\entity.controller.inc on line 261

Warning: Creating default object from empty value in \sites\all\modules\rules\includes\rules.core.inc on line 57

Fatal error: Call to undefined method stdClass::events() in \sites\all\modules\rules\includes\rules.plugins.inc on line 767

2 Answers 2


Debugging is the art of eliminating all possible causes for your problem. Below are some attempts to help you to find the real cause of your issue ...

1. Enable Rules debugging

Something that might help you find the answer to your question, is to have a look at Rules debugging ... Within the Rules settings, experiment a bit with the debugging facilities that come with Rules. At least have a look at the "Rules Evaluation Log" (to check that the Rules logic being executed, actually matches what you expect that logic to be).

For way more details about Rules debugging, refer to the answer to "How can I display the value of a variable inside a condition?".

2. Disable all active rules and re-enable them one by one

Instead of "disable" of the Rules module (which will possible resolve your issue until you enable it again), try to leave it enabled. But start with a disable of all Active (enabled) rules.

If it is some custom rule that is causing your problem, if none of your rules are active, the problem should have disappeared also after you disabled all active rules. If that's the case, re-enable your rules again, one by one, do some test to ensure the rule you enabled did execute. Keep doing this until you hit the custom rule that makes the issue come back again. Then disable that rule again, and check if there are other remaining rules that also make the problem show up again. In the end, try to adapt the rule(s) that seem to cause the issue so that the problem no longer shows up. If you cannot solve it, do not re-enable that rule anymore and think of some alternative.

3. Special watchdog entries

Make sure to also check for any unexpected watchdog entries, it may help to get a clue about what is happening


Try to re-download Rules module and re-try again. So basically remove Rules folder and re-download it again manually or use drush command, e.g.:

drush -y dl rules

For 2.x-dev version, add --dev.

After that clear you caches. If you're using any external caching such as Memcached or Redis, clear it as well. Then re-try again

Source: Error at time of installation of Call to undefined method stdClass::events().

If above won't help, the unserialize() notice suggests that your configuration data is corrupted. As per PHP docs:

In case the passed string is not unserializeable, FALSE is returned and E_NOTICE is issued.

So basically you need to identify the table of your entity ($this->entityInfo['base table']/$schema['fields']) and which row it refers to (fields column). Ideally by setting up the breakpoint or manual code right after unserialize() call.

In other words, edit includes/entity.controller.inc file, find load() method and modify something like below:

  $record->$field = unserialize($record->$field);
  if ($record->$field === FALSE) { // Check if field is unserializeable.
    var_dump($record->$field, $record, $field); // Or use dpm(), dd(), etc.
    // exit(); // Optional exit to improve the formatting.

If you've found some certain pattern, find the corrupted row by:

drush sql-dump --ordered-dump | grep some_unique_field_pattern

Then either correct the corrupted serialized data, restore from the backup or remove the corrupted field data.


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.