Problem/Motivation

When content translation is enabled, the \Drupal\paragraphs\ParagraphAccessControlHandler::checkAccess method doesn't respect if translations are varying on the status field, resulting in access only being determined by the original paragraph language.

Methods such as Paragraph::isPublished() do not respect the current translation, only the original one.

Steps to reproduce

Create a paragraph type which can have a nested paragraph.
Configure the parent paragraph type to expose the publish field.
Enable content translation.
Allow the status (publish/unpublish) field to vary depending on the translation.
Create a page with the target paragraph type and nested paragraphs.
Edit the page to add a second paragraph and nested paragraphs with a differing structure.
Unpublish the second paragraph.
Translate the page, unpublish the first paragraph, publish the second one.

Proposed resolution

Update \Drupal\paragraphs\ParagraphAccessControlHandler::checkAccess() to get the current translation from the language manager, and load the paragraph in that translation before checking access.

Remaining tasks

Create patch.

User interface changes

None.

API changes

None.

Data model changes

None.

Issue fork paragraphs-3593590

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

socketwench created an issue. See original summary.

paucala’s picture

This patch worked for me, thank you.
I think this was some kind of regression, cause it worked till recently

socketwench’s picture

The above commit also gets the translation of the parent paragraph too, as that edge case can recreate the regression.

socketwench’s picture

Status: Active » Needs review

Merged in recent changes.

socketwench’s picture

Updated the patch to get the current language using TYPE_CONTENT. If the user has configurations set to keep the interface language different than the content language (common for multilingual teams), the wrong translation will be used in the access hook.