I started using workflow on a project and discovered workflow access not working as expected for me.
I am using workflow field as it is recommended on the modules page, even though I am only using workflow on 1 node content type.
I just need to know if workflow access is working when using workflow field or is it a problem with my site.
Comments
Comment #1
2phaupon further investigation, it seems that when saving a node with a workflow field on it, the function
workflow_node_current_state($entity, $entity_type = 'node', $field_name = '')is being called twice.Once with the third argument correctly set as the name of the field, which results in the expected $sid, the second time it is called with the third argument not set which returns the default $sid
Comment #2
2phaAfter some more tinkering I got it working.
This will only work for workflow fields on node entities.
I would usually supply a patch, but am in a hurry.
I changed the
workflow_access_node_access_records($node)function to:Comment #3
wouser commentedAnother solution is to actually use Workflow Node; I was told that this is the correct module (Not Workflow Field). Apparently the verbiage on the module description is misleading, or so I was told. I spent over a week trying to get the Field module to work when Workflow Node works perfectly (with Workflow Access). Do yourself a favor, start over and use Workflow Node and make sure you are not using any other access modules as they will interfere.Reference: https://drupal.org/comment/8473529#comment-8473529(A previous frustrated Workflow Field user)
M
Comment #4
johnvHi Wouser, I'm sorry you feel this way. Unfortunately, I was not able to update all submodules on time for you. Until shortly, workflow_vbo was not working, and workflow_access is now solved with 2pha's help. Like all of us, I too need the community to get over my time and knowledge limitations.
So, I took the code above from 2pha (thanks), put it in workflow_node_current_state(), checked some other instances and committed it in this commit.
Now, workflow_access works with workflow_field, too.
Also the third-party module workflow_fields (not the extra S) works, too!
Please download dev release to test this version.
Comment #5
johnvComment #6
wouser commentedMy apologies John, my intent was not to attack you, Previous to now I was under the impression that Workflow Node was the default Module to use and here I was hearing otherwise, hence my frustration. I would have been able to understand not being able to jump on my problem as soon as it arises, especially when there is a lot of troubleshooting to be done but I am glad to hear that it is now working.
Fortunately for me I have been developing everything except Workflow, hoping something like this would arise and it couldn't have come at a better time.
Please don't misunderstand; what you guys have done here is exceptional; it is a core functionality of the website I'm developing that I plan to use for many years with the strong hope of being able to compensate you developers for all of the time and stress that goes into this. For now I am just another person with a dream..ready to watch everything come together; stress is a known factor to be figured in.
Accept my apology. I will download the dev version and start doing some testing!
Thank you.
Comment #7
johnvHi Wouser, it's OK, I can imagine your frustrations. Good luck!
Comment #9
Ivan Simonov commentedHi John!
Looks like you did not update "workflow_access/workflow_access.module"
I still not able to use workflow_access for nodes with workflow_filds.
And add, please, clarification of the access setup under "/admin/config/workflow/workflow/access/1" page.
Present warning can not help to find right way of setup.
Warning: Use of the "Edit any," "Edit own," and even "View published content" permissions for the content type may override these access settings.
Thanks,
Ivan.
Comment #10
2phaworkflow_access has been updated. It is what this thread was originally about.
Comment #11
johnvHi Ivan, you should use 7.x-2.2. Are you?
- If you have problems with the 'weight'/'priority' of the access modules, got to the workflows configurations page. You'll fine 'Workflow access settings', where you can set the weight.
- Perhaps Workflow Access doesn't work for Workflow Field, see #2220065-10: workflow_access_node_access_records() call from node_save() problem with workflow_node
I'll take a look at the help texts.
Comment #13
johnvIvan Simonov was right in #9: when saving the Workflow Access data, no access_rebuild was triggered for Workflow Field, only for Workflow Node. This is now fixed with the above commit.
Comment #15
johnv@Ivan Simonov , the commit in #14 shuffles the pages and the help texts.
I cannot clarify the help texts, since they exist already for years, and I am no expert in access module. Please contribute om improvements once you have figured thins out, or create a sub-page under https://drupal.org/node/872876.
Close the issue if you ae happy now.
Comment #16
Ivan Simonov commentedJohn, thanks for fast reply.
Ufter last updates (dev version) I am still have troubles.
I have "story" type of nodes with attached workflow field. Field can be "draft" and others.
I need to block changes of node when status is not "draft"
So workflow access is:
- read allowed in any state for author
- edit allowed (checked) for author only in "draft" state
other roles unchecked
This settings do not work with any priority for workflow access (-10...0...+10)
Access rebuild does not help.
If role has right "story:edit own material" - it can edit own nodes in any states.
If role "story:edit own material" unchecked - it can not edit own nodes in any states.
What I doing wrong?
Comment #17
Ivan Simonov commentedMay be it helps:
Comment #18
johnvHi Ivan, the code you mentioned has changed the last 48 hours. The new dev version should be better
Comment #19
Ivan Simonov commenteddrush dl workflow --dev -y
Comment #16 still true.
Comment #20
Ivan Simonov commentedI just download dev version from drupal.org
7.x-2.x-dev gz (115.16 KB) | zip (157.5 KB) 2014-Mar-31 Notes
For this version comment #17 true too.
Line 133: return $grants; // <---- exit !!
Comment #21
johnvYes, but the lines above have changed, and some code from the other recent node_access issues, regarding "$node->workflow_transitions", so none of the node with a workflow should go to that line.
Comment #22
Ivan Simonov commentedOk, forgot my messages about code. I try to help.
Workflow access fail in my scenario. All settings ignored. Drupal standard permissions works instead.
New clean Drupal installation just show the fact: workflow access for fields not works.
Please read #16 and test commit. Thanks.
Comment #24
johnvIndeed, grants were not calculated when rebuilding access.
Please try again with latest dev.
Comment #25
johnvComment #26
Ivan Simonov commentedYes! Much better!
Deny edit own content for some roles (drupal permissions).
Allow edit own content in "draft" state for this roles (WF Access).
Rebuild permissions. After this it works as expected.
Thank you.
Comment #27
johnv☺ please reopen or open a new issue if follow up problems arise.
Comment #28
Ivan Simonov commentedAfter last update can not add new node.
Got white screen and fatal errors in log:
PHP Fatal error: Class 'WorkflowTransitionController' not found in .../includes/common.inc on line 7837, referer: .../node/add/article
Warnings in database:
Warning: class_implements() [function.class-implements]: Class WorkflowTransitionController does not exist and could not be loaded в функции entity_crud_get_info() (строка 721 в файле .../sites/all/modules/entity/entity.module).
Warning: in_array() expects parameter 2 to be array, boolean given в функции entity_crud_get_info() (строка 721 в файле .../sites/all/modules/entity/entity.module).
Comment #29
johnvDid you refresh cache, run update.php?
Comment #30
johnvIt seems this happens when both workflow_field and workflow_access and workflow_actions are enabled.
See #1421518: PDOException: SQLSTATE[23000]: Duplicate entry in {node_access} table: when assigning a workflow to the node.
For the time being, I have the following 4 work-arounds:
- disable workflow_actions (everybody uses Rules)
- in workflow_actions.module, function workflow_access_workflow(), remove the call to node_access_acquire_grants();
- in workflow_actions.module, remove 'workflow_actions_entity_update()' from the code.
- in workflow_access.workflow.inc, remove the call to node_access_acquire_grants($entity)
Comment #31
Ivan Simonov commentedrefreshing cache, and update.php helps.
If I will see this error again, I`ll use your recommendations.
In my case workflow_field and workflow_access and workflow_actions was enabled.
Now workflow_actions is disabled.
Comment #34
johnvThe above 2 commits tackle the root cause: an extra hook_workflow('post transition') was triggered, which was not necessary.
Comment #36
johnv