Content Translation interferes when viewing unpublished translations

Created on 12 September 2020, about 4 years ago
Updated 20 August 2024, 3 months ago

Problem/Motivation

The Content Translation module stops unpublished translations from being viewed via access token. This is happening because of logic implemented in content_translation_language_fallback_candidates_entity_view_alter(). When route parameter expansion occurs, the fallback hook's implementation says "you're trying to access this unpublished translation without permission, I'm going to remove this language as a valid fallback so you can't see this translation", which results with the entity ultimately loaded as if it were the source translation.

Given the above, this results in:

1. The access check failing when it should not.
2. Even if the access check succeeded, the entity you are looking at is always representative of the source translation.

Steps to reproduce

1. Install Content Translation and Content Moderation.
2. Add a second language.
3. Add an entity.
4. Translate the entity, leave unpublished.
5. Generate an access token.
6. Confirm using the token to view the source translation works.
7. Confirm that using the token to view the translated content results in access denied.

Proposed resolution

The logic implemented in content_translation_language_fallback_candidates_entity_view_alter() needs to be worked around somehow. My proposed solution is for Access Unpublished to remove Content Translation's implementation of the hook, and then invoke it on its own if the current user does not have permission to view the current entity.

πŸ› Bug report
Status

RTBC

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States lpeabody

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

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