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
| Comment | File | Size | Author |
|---|---|---|---|
| #22 | unpublished-node-permissions-mixed-translation-status.patch | 663 bytes | rhayun |
| #15 | unpublished_node_permissions_translation.patch | 2.26 KB | ipitbiz |
| #12 | unpublished_node_permissions_translation.patch | 2.25 KB | rsayago |
| #11 | unpublished_node_permissions_translation.patch | 2.25 KB | rsayago |
Issue fork unpublished_node_permissions-3425701
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
Comment #6
bohus ulrychHello,
MR 14 generates error
After adding missing line
use Drupal\Core\Access\AccessResult;it seems that it works and solved the problem with translations.
Thanks
Comment #7
m.anoune commentedComment #8
astonvictor commentedIt'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 useunpublished_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...
Comment #9
bohus ulrychYes, now it works!
Comment #10
jurgenr commentedWe'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.
Comment #11
rsayago commentedI 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.
Comment #12
rsayago commentedThis patch is to 8.x-1.5 version.
Comment #13
ipitbiz commentedHello,
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,
Comment #14
ipitbiz commentedHello 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.
Comment #15
ipitbiz commentedThe final patch that fixes both problems. The reason is that gid cannot be null.
Comment #16
quotientix commentedPatch doesn't work for me. This makes the module unusable for me -.-
Comment #17
jksloan2974 commentedYou have to rebuild permissions after you apply the patch
Comment #18
papagrandeI 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.
Comment #19
fabsgugu commentedComment #22
rhayun commentedThis is not fixed in 8.x-1.8 — the scenario in the summary still reproduces verbatim on Drupal 11.4. I cannot reopen (maintainers only), so I have filed #3621675: Published translations of a partly unpublished node get no access record, so they 403 for every user with the full analysis and a patch. Noting it here so followers of this issue see it.
Short version: the per-translation patch from #11/#12/#15 did fix the unpublished side — grants are now written per langcode. But
unpublished_node_permissions_node_access_records()emits nothing for the published translations, and core only adds its default "all" grant when the whole returned array is empty (NodeAccessControlHandler::acquireGrants()). One unpublished translation makes the array non-empty, so the default is skipped for the entire node, and the published translation ends up with nonode_accessrow at all.NodeGrantDatabaseStorage::access()filters per langcode, so nothing matches and it 403s.It is symmetric — the mirror case (published original, unpublished translation) fails the same way. And View any unpublished content does not help either, because rows in that realm exist only for the unpublished langcode. Only
bypass node accessgets through, which is why this looks fine to an administrator.@quotientix, #16 — I suspect "patch doesn't work for me" was this. Worth retesting with the patch on #3621675: Published translations of a partly unpublished node get no access record, so they 403 for every user.