Perform access check on the selected language instead of requested

Created on 20 July 2023, over 1 year ago
Updated 3 August 2023, over 1 year ago

Problem/Motivation

When using database index search (search_api) , entities that do not have translations in the current content language, are not shown to non-admin users.

Steps to reproduce

  • Create a database Search API index
  • Create a view listing nodes
  • Set up fallback chain, say, de => en
  • Create a published node in en without translation to de
  • This node does not appear in search results

This happens because Drupal\search_api\Plugin\search_api\datasource\ContentEntity::getItemAccessResult() performs access check on the current language' entity, which does not exist.

Proposed resolution

  • Store the actual language of the item
  • Perform the access check on the fallback entity
  • Implement hook_entity_access() to allow access

Remaining tasks

Provide a patch

User interface changes

None

API changes

None

Data model changes

None

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇧🇬Bulgaria valthebald Sofia

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

Comments & Activities

Production build 0.71.5 2024