Right now, notification triggers a notification event in notifications_content_nodeapi("insert"...). If, for example, a user is subscribed to a taxonomy term that matches the node being inserted, the node insert notification event will match their taxonomy subscription. If immediate notifications are enabled, this means that notifications_process_rows() is called while still within the node_invokenodeapi() rounds.
This causes a problem, as node_save() calls node_access_acquire_grants() AFTER the various nodeapi calls, which means when notifications_process_rows() calls notifications_user_allowed(), that the node_access grants have not yet been written for the node being inserted, which potentially results in notifications_content_node_allow() indicating that the user does NOT have access to the node being inserted, when after the grants are written, they may indeed have access.
Example Scenario:
- Drupal 5.9
- OG 5.7 with og_access enabled
- notifications/notifications_content/notifications_tags 5.x-1.0-rc1
- "immediate sending" is checked in notifications configuration
- mimemail enabled
- content type in question: 'story'
- 'story' content type associated with vocabulary 'topics'
- Access to 'story' nodes in groups is limited to group members
- User1 is a member of 'example group' (an og group)
- User1 is subscribed to the 'topics' term 'term1' with immediate notification
- User2 (also member of 'example group') submits a story node tagged as 'term1' with audience of group 'example group' not marked public
Expected Behavior: User2 should receive notification email of a new story node being created.
Actual Behavior: No email is sent to User2.
Suspected reason: notifications_content_node_all() reports that User2 does not have access to the new story node. This happens due to immediate sending happening before the node access grants are written.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | fix-immediate-notifications-for-nodes-with-node-access-289211-D7.patch | 1.92 KB | webflo |
Comments
Comment #1
jose reyero commentedInmediate sending has been moved to hook_exit(), this should fix the issue.
Comment #2
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #3
webflo commentedHey this bug is an regression. hook_exit() is removed (e86557d). Notifications for nodes are send via hook_node_insert / hook_node_update.
Here is a backtrace for quick reference.
node_access() is called in Notifications_Node->user_access (#0) but node access for this is not build yet. Because its build in node_save after node_invoke($node, 'insert').
Here is the relevant part form node_save.
Whats the best way to fix this? Implement hook_exit in notifications_content.module again and trigger all content notifications?
Comment #4
webflo commentedDrupal core issue #690520: Calling node_access() from inside hook_node_save() results in wrong access for new nodes
Comment #5
webflo commentedWorkaround via hook_exit(). It works but is very ugly.
Comment #6
zeezhao commented+1. Please is this applicable to latest dev version? I still have issues with getting notifications... Thanks
Fyi - I am using acl & content_access modules
Comment #7
webflo commentedYes its sill an issue. Its not committed yet. The patch should apply.
Comment #8
webflo commentedCommitted the patch. I track the core issue.