Unpublish paragraph doesn't work correctly in multilangual

Created on 15 August 2017, almost 7 years ago
Updated 31 October 2023, 8 months ago

Hi,

We have a bug which happens in multilangual site.

We have contents with many paragraphs. Each paragraph can be un/publish independantly of the language. So, if we want to see a paragraph in english but not in french, we can unpublish the paragraph in french.

All content have been created in french in the first time, next translated in english. If we unpublished some paragraphs in content in french, the behavior is correct: Paragraphs are remove of the view mode in french and appear correctly in english for all users.

But, we have a bug if we do this in english:
If we unpublish a paragraph in a content in english, the paragraph is hidden when we are connected, like wanted. But, anonymous users see the paragraph in french on the english page.

I inspected the code and found the lines which cause the bug in the function paragraphs_type_permissions_paragraph_access (file paragraphs_type_permissions.module, line 35)

if ($operation == 'view' && !$entity->status->value) {
    return AccessResult::forbidden();
  }

If I'm connected, the status is 0, as expected. If I'm an anonymous user, the status is 1 and I don't know why.

So, when we are anonymous, instead of remove the paragraph of the view, the code continue and do a weird behavior.

πŸ› Bug report
Status

Needs work

Version

1.0

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada clairedesbois@gmail.com Montreal

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.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

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.

  • πŸ‡ͺπŸ‡ΈSpain nachosalvador Alicante

    Patch #21 works for me

  • πŸ‡©πŸ‡ͺGermany quotientix

    The patch doesn't work for me. I did a workaround via CSS and Twig:

    In the paragraph-Template I set the class:

    'lang-' ~ paragraph.get('langcode').value

    Via CSS I hide the "other" language:

    html[lang=en] {
      .paragraph.lang-de {
        display: none !important;
      }
    }
    
Production build 0.69.0 2024