A user found this in XML sitemap. I use hook_node_save() to 'index' nodes as sitemap links and I call node_access('view', $node, drupal_anonymous_user()) in order to check if the node is accessible to anonymous user. The problem is that for new nodes, in node_save(), hook_node_save() is invoked before node_access_acquire_grants(), so the value of node_access() is not correct.
Comments
Comment #1
dave reidOriginal discovered issue was #690120: Cannot reliably check node_access from inside hook_node_save() with node grants
Comment #2
webflo commentedRelated issue in Notifications #289211: Immediate notifications on nodes with node access fails.
Comment #3
joelstein commentedA workaround for anyone experiencing this is to simply reset the node_access cache in a custom module: