Unable to change non-translatable field value on translatable content with content moderation enabled

Created on 22 March 2018, almost 7 years ago
Updated 28 April 2023, over 1 year ago

Unable to change non-translatable field value on translatable content with content moderation enabled, because of EntityUntranslatableFieldsConstraintValidator::validate

To reproduce:
1) Install D8.5.0 with the standard profile in EN language.
2) Enable content moderation on Article node type.
3) Enable 'Content Translation' (with dependent Language) module.
3) Add another language.
4) Enable translation of Article content type at Configuration --> Content language and translation, set all fields translatable, except Tags.
5) On manage fields, disable 'Users may translate this field' for Tags field.
6) Add new Article node, with e.g. 'Test' tag and publish content.
7) Create new draft on the created node and change Tags field - e.g. delete 'Test' tag, or add another one.

You wouldn't be able to save the node because of validation error:
Non-translatable fields can only be changed when updating the current revision.

Solutions:
a) the EntityUntranslatableFieldsConstraintValidator::validate() should check if the content isModeratedEntity() or
b) content moderation module should extend EntityUntranslatableFieldsConstraintValidator::validate()

🐛 Bug report
Status

Active

Version

10.1

Component
Content translation 

Last updated 3 days ago

No maintainer
Created by

🇭🇺Hungary szato

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

Merge Requests

Comments & Activities

Not all content is available!

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

  • 🇷🇸Serbia ratvas Novi Sad

    I highly recommend to avoid solution #3 (or #26) as removing constraints is not a solution, but workaround which can cause other issues.
    Solution still needs to be found, or at least more precise log message in order to point developer in a right direction.
    In my case, I was going through the /admin/config/regional/content-language list and check one by one entity and field so that brought me the result. I had some iframe field checked for translation and unchecking that field allowed me to translate content without issues.

  • Status changed to Needs review over 1 year ago
  • last update over 1 year ago
    Custom Commands Failed
  • 🇺🇦Ukraine bvakulin

    This is raw decision for solution #a) (from description of this problem). Needs review this patch.

  • last update over 1 year ago
    29,463 pass, 2 fail
  • 🇺🇦Ukraine bvakulin

    Some changes in patch. Fixed failed test issue.

  • Status changed to Needs work over 1 year ago
  • 🇧🇷Brazil brandonlira

    The patch #69 works well for me on D10.1.4

  • First commit to issue fork.
  • Pipeline finished with Failed
    12 months ago
    #81708
  • Pipeline finished with Failed
    12 months ago
    #81712
  • 🇩🇪Germany jurgenhaas Gottmadingen

    I've turned this into an MR and fixed some code style issues from the patch.

    However, the PHPUnit tests are failing since the new code requires a service which is not available in the test context. I guess, this needs dependency injection instead of loading the service with \Drupal::service('...').

  • Pipeline finished with Running
    12 months ago
    #81761
  • Pipeline finished with Failed
    12 months ago
    #81772
  • Pipeline finished with Failed
    12 months ago
    #81780
  • Pipeline finished with Success
    12 months ago
    #81792
  • Status changed to Needs review 12 months ago
  • 🇩🇪Germany jurgenhaas Gottmadingen

    Phew, a couple of iterations and I got all the test green. This is now ready for review.

  • Status changed to Needs work 12 months ago
  • 🇺🇸United States smustgrave

    As a bug will need test coverage to make sure it doesn't break in the future.

  • 🇧🇪Belgium JeroenT 🇧🇪

    Uploaded a patch for composer patches.

  • 🇩🇪Germany tobiasb Berlin

    Fyi: The patch file is the history of all commits. Better is to use just the diff for composer-patches.

  • 🇺🇸United States awolfey

    #77 is working for us. Thank you.

  • 🇮🇳India basavarajhavaler

    The patch is solving the issue but I have noticed a new Issue.

    Steps to reproduce :

    1. Add multilingual capability to site with at least 2 languages.
    2. Have moderation enabled.
    3. Create a node & publish in default language.
    4. Go to node translate tab, Click on another language to add translation in NEW tab.
    5. Try to add content - draft -> needs review -> Publish
    6. But It wont allow to publish It throws error. - The submitted value needs_approval in the Change to element is not allowed.
  • 🇮🇳India basavarajhavaler

    The patch is solving the issue but I have noticed a new Issue.

    Steps to reproduce :

    1. Add multilingual capability to site with at least 2 languages.
    2. Have moderation enabled.
    3. Create a node & publish in default language.
    4. Go to node translate tab, Click on another language to add translation in NEW tab.
    5. Try to add content - draft -> needs review -> Publish
    6. But It wont allow to publish It throws error. - The submitted value needs_approval in the Change to element is not allowed.
  • Assigned to basavarajhavaler
  • 🇮🇳India basavarajhavaler

    The patch is solving the issue but I have noticed a new Issue.

    Steps to reproduce :

    1. Add multilingual capability to site with at least 2 languages.
    2. Have moderation enabled.
    3. Create a node & publish in default language.
    4. Go to node translate tab, Click on another language to add translation in NEW tab.
    5. Try to add content - draft -> needs review -> Publish
    6. But It wont allow to publish It throws error. - The submitted value needs_approval in the Change to element is not allowed.
  • Issue was unassigned.
  • 🇧🇪Belgium stefvanlooveren

    #77 is giving me problems on a multilingual website with content moderation and paragraphs: when created the translation, paragraphs are not accessible anymore both on the default language as on the translation.

  • As per #2, I believe this is expected behaviour, and opting out of it for content moderated content probably isn't advisable, and would cause more issues.

    I'd recommend that all development efforts are placed into 🐛 New non translatable field on translatable content throws error Needs work since that addresses the actual issue at hand (stopping it from applying data from non-translatable fields when they're inaccessible).

    Depending on how the module works, using this patch can also result in loss of data if the widget returns an empty value when it detects that translations are unsupported as per my smart_date patch (which is probably why Paragraphs are a problem as per @stefvanlooveren - see #3194515-4: Smart Date Recurring doesn't work in non translatable field )

Production build 0.71.5 2024