Problem/Motivation

ViewsReferenceExtrasCompressionReload overrides core's viewsreference.compression service so links generated by the embedded view (pager links, exposed filter form submissions) carry only compressed entity identifiers instead of the full serialized settings. On uncompress(), the parent entity is reloaded via $entity_storage->loadRevision($reload['parent_revision_id']) with no notion of language, then its Views Reference field is read directly.

On a multilingual entity whose Views Reference settings differ per translation (e.g. a "restrict results to this translation's language" setting, common on multilingual listing/search blocks), loadRevision() returns the entity's default translation. Any translation-dependent settings are then read from the wrong translation.

Concretely: viewing a non-default-language translation of a node whose embedded Views Reference block is configured to restrict results to that translation's language works correctly on first page load. But submitting the view's exposed filter form, or clicking a pager link - both of which carry the "reload" parameter - silently drops that language restriction because it's re-derived from the entity's default-language translation.

Steps to reproduce

  1. Create a translatable entity with a Views Reference field, enabled setting "Restrict to language" (or another per-translation setting).
  2. Give the default translation (e.g. English) one value for that setting, and a non-default translation (e.g. Spanish) a different value.
  3. View the non-default translation - the block reflects its own setting.
  4. Submit the exposed filter form (or click a pager link) - the setting reverts to whatever was configured on the default translation.

Proposed resolution

uncompress() should call $entity->getTranslation($langcode) - using the langcode the field was originally rendered in - before reading the field. This requires viewsreference to expose that langcode in the #viewsreference array; see companion issue #3609894 on the viewsreference project.

Remaining tasks

Depends on #3609894 (viewsreference) landing first.

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

tyapchyc created an issue. See original summary.

tyapchyc changed the visibility of the branch 3609896-ajaxexposed-filter-reload-compression to hidden.

tyapchyc changed the visibility of the branch 3609896-ajaxexposed-filter-reload-compression to active.

tyapchyc’s picture

scott_euser made their first commit to this issue’s fork.

  • scott_euser committed 644dd228 on 1.0.x authored by tyapchyc
    fix: #3609896 AJAX/exposed-filter "reload" compression loses translation...
scott_euser’s picture

Status: Needs review » Fixed

Thank you! Added test coverage and merged

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.