Problem/Motivation

On multilingual Drupal sites, Entity Mesh can incorrectly detect an "access denied" condition for media entities referenced from nodes when the referenced media item has not been translated.

This happens when:

  • A node is translated into multiple languages.
  • The node references a media entity.

The referenced media entity exists only in its original language and has no translation for the node's current language.

In this scenario, Entity Mesh checks access to the referenced media using the node translation language instead of the language actually used by the media link. Since the media has no translation in that language, Entity Mesh interprets this as a lack of access and reports a false positive.

The expected behavior is to evaluate access against the media entity in the language that the media link resolves to (typically the original/source language of the media), rather than assuming the node language must also be the media access-check language.

Steps to reproduce

  • Enable multilingual support on a Drupal site.
  • Create at least two languages (for example, English and Spanish).
  • Create a media entity in the default language only (for example, English).
  • Do not create a translation for that media entity in the second language.
  • Create a node in English and attach/reference the media entity.
  • Translate the node into the second language (for example, Spanish), while keeping the same media reference.
  • Run Entity Mesh processing, validation, or synchronization that performs access checks on referenced media.
  • Observe that Entity Mesh reports an access denied issue for the media when evaluating the translated node.

Proposed resolution

Update Entity Mesh media access validation logic so that access checks are performed against the correct translation context of the referenced media entity.

Possible implementation approach:

  • When resolving a referenced media entity from a translated node, determine the actual language of the media entity being linked/rendered.
  • Perform the access check on the loaded media translation that actually exists, rather than forcing access evaluation in the node translation language.
  • Only report access denied if access is truly denied for the resolved media translation.

Remaining tasks

  • Update the Entity Mesh access-check logic for referenced media in multilingual contexts.
  • Add test coverage for untranslated referenced media on translated nodes.
  • Add test coverage for fully translated media to confirm no regression.
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

lpeidro created an issue. See original summary.

lpeidro’s picture

I have merged the issue.

lpeidro’s picture

Status: Active » Reviewed & tested by the community

lpeidro’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.