This issue is a follow-up of issue "Error multilingual node" to target the issue more precisely.

People cannot use PbT with the content translation module. Because they get errors. PbT sets 1 language per node. There should be no language set by PbT. Drupal's node access records are able to handle this automatically.

Workaround

Do not enable the content translation module, but enable the

  • locale
  • language

modules. Then you can specify a language for your nodes, by preserving a separate node id for each node. If you do not need separate permissions for each language, then this issue is not affecting you at all.

CommentFileSizeAuthor
#10 support-content-translation-2922739-10.patch990 bytesrwam

Comments

Peter Majmesku created an issue. See original summary.

jepster_’s picture

Title: Support content translation module and store the language key in PbT's DB tables » Support the content translation module and store the language keys in PbT's DB tables
jepster_’s picture

Issue summary: View changes
amairesse’s picture

I am facing the access denied issue related in https://www.drupal.org/node/2866284.
I do not need separate permissions for each language but the website is translated in a "normal fashion", meaning using the Content Translation module - common node ID for all languages. We could not maintain this large translated website without Content Translation module enabled.

Is there any way PbT can work in this configuration ?

rwam’s picture

Version: 8.x-1.35 » 8.x-1.41
Category: Feature request » Bug report
Priority: Normal » Major

Same problem here like @amairesse.

I think the problem is situated in missing entries in table node_access. I've made some tests and this are my results:

1. add a node and a translation (no tag)

database entries (table node_access – columns nid langcode fallback gid realm grant_view grant_update grant_delete):

1486	de	1	0	all	1	0	0
1486	en	0	0	all	1	0	0

result: each translation is visible for all users

2. edit a node and add a restriced tag (»Only access by authenticated users«)

database entries:

1486	en	0	1486	permissions_by_term	1	0	0

result: english works as expected, but german is only accessible for administrator.

3. update database by duplicate row with changed language key

database entries:

1486	de	0	1486	permissions_by_term	1	0	0
1486	en	0	1486	permissions_by_term	1	0	0

result: each translation is visible for authenticated users – it works

4. update of the node leads delete the translated row ;-(

database entries and result: see 2.

Summary:

The missing entry for the translation in node_access leads to the error.

I would change priority to »Major« because the module is not usable for multilingual sites at the moment.

jepster_’s picture

Status: Active » Postponed (maintainer needs more info)

You are just repeating, what is already written in the description of this issue. The content translation module is not supported at the moment. Take a look on the workaround.

What's needed to support the content translation module, is already described in the issue description.

Feel free to create a patch and post it here to add the missing feature for your use-case. You can also create a pull request via the PbT Git repository at GitHub. It is your use-case. I do not need this feature personally. This would be a really good contribution from your end.

jepster_’s picture

Category: Bug report » Feature request
jepster_’s picture

I have updated PbT's project description to avoid confusion.

If you can't provide a patch: please contact me via the contact form on my user profile, if you would like to provide funding to get this feature done.

PbT is an open-source software project. You are already saving a lot of time and money by using the current PbT version. It would just be fair, if you would provide support for implementation of this feature for your purpose.

jepster_’s picture

Status: Postponed (maintainer needs more info) » Active
rwam’s picture

Status: Active » Needs review
StatusFileSize
new990 bytes

The description of hook_node_access_records() mentioned the following:

langcode: (optional) The language code of a specific translation of the node, if any. Modules may add this key to grant different access to different translations of a node, such that (e.g.) a particular group is granted access to edit the Catalan version of the node, but not the Hungarian version. If no value is provided, the langcode is set automatically from the $node parameter and the node's original language (if specified) is used as a fallback. Only specify multiple grant records with different languages for a node if the site has those languages configured.

So I've created the attached patch which solved the problem for me. After applying the patch you have to rebuild the permissions by running database updates with running update.php or drush updb or using of /admin/reports/status/rebuild.

  • Peter Majmesku committed 557805e on 8.x-1.x authored by rwam
    Issue #2922739 by rwam: Support the content translation module and store...
  • Peter Majmesku committed 735da6b on 8.x-1.x
    Issue #2922739 by Peter Majmesku: Modified version in update hook to...
jepster_’s picture

Title: Support the content translation module and store the language keys in PbT's DB tables » Support the content translation module
jepster_’s picture

Issue summary: View changes
jepster_’s picture

Thanks! Looks good to me. I have patched PbT and released your fix with version 8.x-1.42: https://www.drupal.org/project/permissions_by_term/releases/8.x-1.42. I have modified the update hook a bit, to match the current release version.

Closing this issue. Please feel free to re-open it, if you have any objections.

jepster_’s picture

Status: Needs review » Fixed
amairesse’s picture

@rwam : Tested, this works fine.

Many thanks!

jepster_’s picture

Glad to read. :)

genat’s picture

Thank you rwam! #10 worked like a charm!!!

jepster_’s picture

Please notice: this fix is part of the current stable PbT release.

jepster_’s picture

Status: Fixed » Closed (fixed)