I created a custom workflow action to change the author UID of the newly created node to a user specified as a field in the node itself. The action works correctly, changing the author properly (by setting the $node->uid then calling node_save($node)). I have verified this by examining the 'node' table after creation.
I am also using the nodeaccess module to restrict accesses to that node type. The user (well, actually the role) who created the node is allowed to 'View' and 'Edit' the node. The newly assigned author is only allowed to 'View' the node, (and only other such nodes of which that user is the author).
Here is the problem. Immediately after the node is created (and the action triggered) if the assigned author attempts to view the node, access is denied. Looking at the 'node_access' table, sure enough the assigned author does not have access to view the node. Then as a user/role with 'Edit' access I re-submit/save the node without making any changes. Afterward, the assigned author has access to view the page, which is verified by the entry in 'node_access'.
How can I make it so that the 'node_access' table is updated properly in my workflow action, allowing the assigned author to view the node, and without requiring another user to re-save the node?
P.S. The access system is a bit over my head and I don't have time at the moment to work through it. So if anyone has some good thoughts on this, I would really appreciate it.
Comments
Similar problem with taxonomy_node_save()
I've encountered a similar problem testing out an action that supposed to add/remove terms to a node:
http://drupal.org/node/135125
Basically, the action will add/remove taxonomy terms for a node and then call taxonomy_node_save() to update the node table. However, calling taxonomy_node_save() does NOT appear to result in any changes made to node access table, which seems to suggest the action code should also be calling an appropriate function in the node access module (in my case Taxonomy Access Control).
As you describe, the only way to get node access updated is to manually edit & re-save the node afterwards.