Mixed original language in content and taxonomy terms does not check access permissions correctly

Created on 12 October 2020, almost 4 years ago
Updated 19 April 2024, 5 months ago

Problem/Motivation

We have a multilingual site with English being the default language. We have both content types and taxonomy terms translated. When creating content users can select the language used to create the content. Basically they are selecting between English and Finnish.

Permissions by Terms works fine when they create English content and term permissions are set to the English terms.

But there seems to be a mix up in languages when user creates a content in Finnish and attaches a term to it because the term default language is English.

When the method canUserAccessByNodeId() is called its getting the current language and the term default language and comparing those together:

if ($termInfo instanceof Term && $termInfo->get('langcode')->getLangcode() == $langcode) {

At least in our setup in the edit page, the current interface language returns fi but the term default language is usually returning en. This prevents the module from going to the code block which is checking for term permissions and always gives access denied to the user.

Proposed resolution

Ideally we could check if there is a translation for the term in the current language and use that in code. If the translation is not found we could fallback to the default language and see if there are matching permissions for that. But this is problematic if there is a situation where the taxonomy term translations would have different permissions attached.

🐛 Bug report
Status

Needs review

Version

3.1

Component

Code

Created by

🇫🇮Finland heikkiy Oulu

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024