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
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 #3
paucala commentedThis patch worked for me, thank you.
I think this was some kind of regression, cause it worked till recently
Comment #4
socketwench commentedThe above commit also gets the translation of the parent paragraph too, as that edge case can recreate the regression.
Comment #5
socketwench commentedMerged in recent changes.
Comment #6
socketwench commentedUpdated 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.