Problem/Motivation

I have node, with translations.
Node in original language is unpublished (English), node with translation is published (French).
With this module enabled, I can' access French version of the node.
After disabled this module, it works.

Note: with view_unpublished it works as expected

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Bohus Ulrych created an issue. See original summary.

AstonVictor made their first commit to this issue’s fork.

m.anoune made their first commit to this issue’s fork.

m.anoune changed the visibility of the branch 8.x-1.x to hidden.

bohus ulrych’s picture

Hello,
MR 14 generates error

The website encountered an unexpected error. Please try again later.
Error: Class 'AccessResult' not found in unpublished_node_permissions_node_access() (line 67 of modules/contrib/unpublished_node_permissions/unpublished_node_permissions.module).

After adding missing line
use Drupal\Core\Access\AccessResult;
it seems that it works and solved the problem with translations.

Thanks

m.anoune’s picture

Status: Active » Needs review
astonvictor’s picture

Status: Needs review » Needs work

It's incorrect to fix it in that way:
- hook_entity_access doesn't work with queries and autocomplete fields. So, your changes create new bugs in other places;
- it makes no sense to remove unpublished_node_permissions_node_grants() but still use unpublished_node_permissions_node_access_records() and rebuild node grants on module install.

you can check the difference between access hooks here - https://api.drupal.org/api/drupal/core%21modules%21node%21node.module/gr...

bohus ulrych’s picture

Yes, now it works!

jurgenr’s picture

We've had the same issue here and moved to https://www.drupal.org/project/view_unpublished. That module does exacly the same thing, and is more globally used than this one.

rsayago’s picture

I have been working on a patch to fix this issue. We have been testing and it seems to works fine. With this patch, the permissions are saved right for each translations on the node_access table in the database. This patch is to 8.x-1.4 version.

rsayago’s picture

This patch is to 8.x-1.5 version.

ipitbiz’s picture

Hello,
I add a small change in the patch because the code of version 1.5 changes a little. Instead of:

'realm' => 'view_unpublished_author',
'gid' => $node->getOwnerId(),

I have:

'realm' => 'view_unpublished_author',
'gid' => $node->getOwnerId() ?? 1,

ipitbiz’s picture

Hello again,

Sorry, I realized that my difference is due to the fact that I have this patch applied also:

https://www.drupal.org/files/issues/2024-03-11/3427115-2.patch

I don't know if the same thing can happen to anyone.

ipitbiz’s picture

StatusFileSize
new2.26 KB

The final patch that fixes both problems. The reason is that gid cannot be null.

quotientix’s picture

Patch doesn't work for me. This makes the module unusable for me -.-

jksloan2974’s picture

You have to rebuild permissions after you apply the patch

papagrande’s picture

Issue summary: View changes

I ran into this problem as well. I fixed it by swapping in the https://www.drupal.org/project/view_unpublished module. Thanks, @jurgenr.

Given the lack of attention to this issue and module and the far lower number of sites using it, I suggest the module be abandoned and sites migrate to view_unpublished.

fabsgugu’s picture

Status: Needs work » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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