We have a module that syncs a user's profile from another server when they log in. However, after a user logs in, the Content update event stops firing.


Steps to reproduce:

  1. Create a rule that act on the content updated event and displays a message.
  2. Create a module with a hook_init that runs before the rules' hook_init
  3. Call a function in the new hook_init that eventually calls module_implements('entity_update'). User_save does this.
  4. Update a content node.
  5. Observe that a message is not displayed.

What I have figured out happens is this:

  1. When user_save runs. It eventualy calls module_implements('entity_update').
  2. Since events.inc is not yet loaded, module_implements caches that rules does not implement hook_entity_update.
  3. Later, when an entity is updated, module_implements uses the cached value and rules_entity_update is not called.

Possible Fixes:
We could move rules_init to run first with hook_module_implements_alter. We could also just include the module/events.inc file in the module.info file. We already load it in init unconditionally. I prefer the second solution as that seems more stable.

Comments

kmorozov’s picture

Issue summary: View changes
reecemarsland’s picture

Thank you for raising this - it helped me track down the issue and temporarily patch my production site! I went for the simple include module/events.inc route.

extremal’s picture

StatusFileSize
new363 bytes

I have a similar problem here, but with the hook entity_view.
Unfortunately placing the module/events.inc into the rules.info file didn't solve it in my case.
So I went with the same solution as ReeceMarsland did and included the modules/events.inc file directly into the module and everything works fine now.

skruf’s picture

Be interested to know why the module includes the file in hook_init(). I would say this is a pretty major bug.

maxplus’s picture

Hi,

I think your patch is committed in the latest 2.7 release.

There is a lot more info around this issue here: https://drupal.org/node/1824088

Thanks for the support!

marcelovani’s picture

Version: 7.x-2.3 » 7.x-2.x-dev
Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.