Problem/Motivation

On the Workflow configuration pages 'tranitions' and 'access', there is no anonymous Role in the Table, only (author) and the Roles described above.

Proposed resolution

After digging around in the Code I found in workflow/modules/workflow_access/src/Form/WorkflowAccessRoleForm:70 the call to workflow_get_user_role_names("create $type_id workflow_transition"), which on the one hand looks wrong (why are you querying for users that can create a transition, when all we want is to view the Content, or am I getting anything wrong here?) and on the other hand calls workflow_get_user_role_names which calls user_role_names(TRUE, $permission));, where TRUE means "no anonymous role", right?
>> Indeed, the boolean must be set tot FALSE.

Original report by [username]

I Have a Site with the Workflow Module using Workflow Access and a Workflow called Content Creation which is used for multiple Content Types.
Furthermore the Site has multiple Roles (Employee, Moderator, Publisher) and the Workflow has multiple Steps (Draft, Checking, Waiting for publishing, Published).
Content should only be viewable by anonymous Users when the Status is "Published".
If I understand Workflow Access right, I would need to set "Roles who can view posts in this state" for anonymous for the Status?
The Problem is, there is no anonymous Role in the Table, only (author) and the Roles described above.
Also the anonymous Role has the right to participate in the Content Creation workflow.
After digging around in the Code I found in workflow/modules/workflow_access/src/Form/WorkflowAccessRoleForm:70 the call to workflow_get_user_role_names("create $type_id workflow_transition"), which on the one hand looks wrong (why are you querying for users that can create a transition, when all we want is to view the Content, or am I getting anything wrong here?) and on the other hand calls workflow_get_user_role_names which calls user_role_names(TRUE, $permission));, where TRUE means "no anonymous role", right?
Am i doing something wrong or is it not possible to give view rights to anonymous users (I think I'm doing something wrong because this would be weird, yes?)

I already deinstalled and reinstalled the workflow module with no luck and spent a lot of time trying to figure this out, so I really think I need help.
Thanks, Alex.

Comments

Miradorn created an issue. See original summary.

johnv’s picture

First of all, happy new year, Alex . I am glad workflow is on top of your mind on the first day of the new year. ;-)

From my memory: I guess you are right, anonymous user should be incorporated, so switching the boolean should help. The permission 'create transition' is the technical name for ''participate in workflows". It is mainly used to keep the list of roles in Workflow Admin UI manageable. So you should give Anonymous this permission. It will appear in your list on Transition roles and Workflow access.

Beware: if a role already has a permission with default permissions, you won t see any effect.

Hope this helps. If not , i ll hear from you again.

Miradorn’s picture

Happy new year to you too!

So to my understanding the method workflow_get_user_role_names would have to be patched, to take a second parameter, which defaults to true and would be passed through to the user_role_names call.
Should I open up a pull request for this change or will somebody else look into this?

Thanks again for your time!

johnv’s picture

Title: Missing Guest Role in Workflow Access » Missing Anonymous Role in Workflow configuration
Category: Support request » Bug report
Issue summary: View changes
Status: Active » Fixed

It is sufficient to change the here:

    $roles[$permission] = array_map(array('\Drupal\Component\Utility\Html', 'escape'),
      array(WORKFLOW_ROLE_AUTHOR_RID => WORKFLOW_ROLE_AUTHOR_NAME) + user_role_names(FALSE, $permission));
  }

The Anonymous role was lost in the 'transition roles' page, too.
I'll fix this shortly.

johnv’s picture

You will need to add the Anonymous/Guest role to the list via the permissions page.

  • johnv committed d26f22a on 8.x-1.x
    Issue #2642990: Missing Anonymous Role in Workflow configuration
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.