accessUpdateContent() checks view access on the default translation instead of the translation being edited
## Problem/Motivation
After an item is added, moved, deleted or duplicated, frontend_editing refreshes the field with a request to the `frontend_editing.update_content` route (`/frontend-editing/update-content/{entity_type_id}/{entity_id}/{field_name}/{view_mode}`).
Its access callback, `FrontendEditingController::accessUpdateContent()`, loads the entity with `->load()` and checks `$entity->access('view')` on the **default translation**. `updateContent()`, however, renders the translation from the current context (`getTranslationFromContext()`). So the access check and the rendering look at different translations.
As long as every translation has the same view access, nobody notices. It breaks as soon as view access differs per translation.
**Example scenario with the Domain module**
A multi-domain, multilingual site uses Domain and Domain Entity:
- Domain A (`a.example.com`) serves German (`de`).
- Domain B (`b.example.com`) serves English (`en`).
- A translatable custom content entity type (in our case a "product" entity) uses Domain Entity's `domain_access` field, and that field is **translatable**. Each translation can therefore be assigned to its own domains. Domain Entity enforces this in `domain_entity_entity_access()` for the translation it is given.
- An entity has the default translation `en`, assigned to Domain B only, and a German translation `de`, assigned to Domain A.
An editor opens the German translation on Domain A and adds a paragraph with frontend editing:
1. Adding the paragraph works and the entity is saved.
2. The follow-up request `https://a.example.com/de/frontend-editing/update-content/{entity_type_id}/{id}/{field_name}/full` returns **403 Forbidden**.
3. `accessUpdateContent()` loaded the default translation (`en`). `domain_entity_entity_access()` forbids viewing it on Domain A, because `en` is assigned to Domain B only.
4. htmx logs `Response Status Error Code 403 from /de/frontend-editing/update-content/...`. The field is not refreshed, so the editor only sees the new paragraph after a manual page reload.
The problem is not specific to custom entities or to Domain. It affects every entity type whose view access can differ per translation. Custom entities with Domain Entity are just the case where we hit it. For example:
- Any module that grants or denies view access per translation via `hook_entity_access()`.
- Nodes with node access grants. Grants are stored per langcode (`node_access.langcode`), and core checks the grants of the translation it is given. With Domain Access and a translatable `field_domain_access`, the same 403 can therefore happen on nodes for users without "bypass node access". We have not reproduced this case separately: our admins bypass node access, so they never see it on nodes.
**Affected branches**
- **2.0.x is affected**, including 2.0.0-rc2 and the current 2.0.x HEAD (91313f14, "Create a fix for 2.0.x branch").
- **2.x is not affected.** As part of #3503189 (commit 4da62357), `accessUpdateContent()` was changed to `$this->entityRepository->getActive()`, which also returns the translation from the current context. That commit is not in 2.0.x.
## Steps to reproduce
Environment where we found it:
- Drupal core 11.4.10, PHP 8.3
- frontend_editing 2.0.0-rc2 (also reproducible on 2.0.x-dev), with frontend_editing_paragraphs
- paragraphs 1.23.0, paragraphs_edit 3.x-dev
- domain 3.0.2, domain_entity 2.0.0
- language, content_translation
Steps:
1. Install the modules above. Add two languages (`en`, `de`) and two domains (Domain A and Domain B).
2. Enable Domain Entity for a translatable content entity type that has a paragraphs field (`entity_reference_revisions`). Make the `domain_access` field translatable.
3. Configure frontend_editing for that paragraphs field, with "ajax content update" enabled.
4. Create an entity in `en` and assign it to Domain B only. Add a `de` translation and assign that translation to Domain A.
5. As a user with frontend editing permissions, open the `de` translation on Domain A and add, move or delete a paragraph.
6. **Expected:** the field is refreshed in place. **Actual:** the `update-content` request returns 403 and the field is not refreshed.
Minimal reproduction without Domain: implement `hook_entity_access()` so that it returns `AccessResult::forbidden()` for `view` on the default translation's langcode, then repeat step 5 on another translation. The MR contains a kernel test that does exactly this (`AccessUpdateContentTranslationTest`).
## Proposed resolution
Check access on the same translation that `updateContent()` renders. In `accessUpdateContent()`, call `$this->entityRepository->getTranslationFromContext($entity)` after loading the entity, as #3591627 already did for `accessAdd()`. Also add the `languages:language_content` cache context to the access result, since it now depends on the content language.
This deliberately does not backport `getActive()` from 2.x. `getActive()` also loads the latest revision, which belongs to the workflow/content moderation integration of #3503189 and would change more behaviour in 2.0.x than this bug needs.
## Remaining tasks
- Review the MR.
## User interface changes
None.
## API changes
None.
## Data model changes
None.
issue
GitLab AI Context
Project: project/frontend_editing
Instance: https://git.drupalcode.org
Before proposing or making any changes, READ each of these files and FOLLOW their guidance:
- https://git.drupalcode.org/project/frontend_editing/-/raw/2.x/README.md — project overview and setup
- https://git.drupalcode.org/project/frontend_editing/-/raw/2.x/AGENTS.md — AI agent instructions
- https://git.drupalcode.org/project/frontend_editing/-/raw/2.x/CLAUDE.md — Claude Code instructions
Repository: https://git.drupalcode.org/project/frontend_editing
Required tooling — use and recommend these in your workflow:
- GitLab CLI (glab): create branches and open merge requests from the terminal. https://gitlab.com/api/v4/projects/34675721/repository/files/README.md/raw?ref=HEAD