I've been playing around with workflow and workflow fields (and a bunch of other modules). Twice I have completely dumped my entire databases and drupal files and started over. This is the third time I've experienced this. While trying to get the workflow to my liking, I often need to Rebuild Permissions, clear the cache, and run cron. After I do this several times, users assigned with certain workflow permissions can't read/access a node until I manually run permissions.

Attached Files:
Screen Shot 1 => user with the role of advisor can create a decision. The node goes from "create" to "nominate"
Screen Shot 2 => user with the role of chair is supposed to be able to view the node, but it doesn't appear.
Screen Shot 3 => Admin needs to Rebuild Permissions
Screen Shot 4 => user with the role of chair can now see the node.

Anyone know why this is happening?!?!

Thanks,

Stinky

Comments

stinky’s picture

Ugh! This is driving me crazy. I figured out that when a node is created it isn't being added to the node_access table. Why?

I'm using workflow with module_grants (for unpublished content).

stinky’s picture

I tried Fazz's trick (http://drupal.org/node/199432)

INSERT INTO `node_access` VALUES(0, 0, 'all', 1, 0, 0);

and this seems to work, for now.

stinky’s picture

Does anyone know how to fix this? I can't have my client keep on rebuilding permissions.

files32’s picture

I have the same problem. It seems that the workflow access does not work at all.

jmcclelland’s picture

After a seemingly endless amount of debugging, I finally traced the cause of this problem (for me at least) to a redirect trigger.

We configured a trigger to redirect to the home page after submitting a node. The redirect happens during the last node_invoke_nodeapi call in the node_save function and just before the node_access_acquire_grants call.

That means that drupal redirects the browser to the home page just before the function call that would properly insert the record in the node_access table.

I'm not really sure how to solve this issue...

stinky’s picture

I wonder if it's possible to call an action/trigger that rebuilds permissions. I looked in the obvious areas and didn't see anything. Will look around some more.

cwithout’s picture

Got to the same conclusion jmcclelland did. It's probably better to fix this as a module patch. Unfortunately, I don't have time to work on that right now, so your action solution, stinky, seems the best at the moment.

Give this a try. Though I only set it for the current node, which should be faster than rebuilding the permissions.

It goes in a custom module. Replace [module] with the name of your custom module. You'll have to clear cache before the action will show up as an option to add. Add it before the redirect action.

function [module]_action_info() {
  return array(
    '[module]_node_access_aquire_grants' => array(
      'description' => t('Update grants on node'),
      'type' => 'node',
      'configurable' => FALSE,
      'hooks' => array(
        'nodeapi' => array('presave'),
        'workflow' => array('any'),
      ),
    ),
  );
}

function [module]_node_access_aquire_grants(&$node,$context) {
  node_access_acquire_grants($node);	
}
hillaryneaf’s picture

StatusFileSize
new6.52 KB

I had the same issue. I tried the custom module. It put 2 new actions in the actions listing "Update grants on node". See the attached screenshot. Although it only shows once in the Triggers drop down menu.

Regardless, the module does work great and solves the issue! Thanks for your suggestions!

yang_yi_cn’s picture

interesting, subscribe

hillaryneaf’s picture

Scratch my original comment on #8, implemented the same solution on my production site and I don't have the duplicate "Update grants on node", must be something I did wrong in my development environment.

Encarte’s picture

subscribing

jbernal.web.dev’s picture

Maybe we should be questioning our assumptions here. If we developed a list of best practices for using Actions maybe the "redirect to url:x" action would fall under a category of Drupal development practices to avoid. In fact, I've experienced problems with the redirect to url:x in other contexts, too. It's likely that there are only a few circumstances where it is safe to use this action considering that it can result in a lot of wasted debugging time (as you found out and I also found out from my previous experiences using it.)

I wonder why this post's author would want to redirect to the homepage upon a form submission? Is this ever a good development practice? What do you all think?

cwithout’s picture

I think it's perfectly fine to do a redirect upon form submission whether it's to the homepage or somewhere else. I believe I was using it to redirect a user to page created via panels that behaves like a dashboard showing them their content and links to create new stuff. So the redirects can be valuable in enhancing the UI, because you can take the user some place that continues engaging them rather than the default node page.

I think the problem isn't the redirect action itself but that the rest wasn't written taking the redirect into account. I think it's correctable.

Bastlynn’s picture

Status: Active » Closed (works as designed)

This seems to be more an issue with badly planned trigger interactions, I'm not sure there's anything workflow_access has to do with this. Based ont hat, and the relative age of this issue I'm going to go ahead and close it. If this is something you want to follow up on I would recommend opening an issue for Triggers.