Problem/Motivation
The \Drupal\content_translation\Controller\ContentTranslationController::overview() method checks update/delete access on an untranslated entity, while the \Drupal\content_translation\Access\ContentTranslationManageAccessCheck::access() checks access on a specific translation. Once an entity access check depends on a value of a translatable field or on the active language of the translation, users may end up seeing access denied, because access to the translation form is denied for users who are able to use the edit form.
Steps to reproduce
- Install Drupal using Standard profile.
- Install 2.x version of Allowed Languages module.
- Enable multiple languages, e.g. English & French.
- Grant the following permissions to the Content Editor role:
- Article: Delete any content
- Article: Edit any content
- Delete translations
- Edit translations
- Translate Article content item.
- Create an Article node in English as admin.
- Translate it into French as admin.
- Create user A of Content Editor role with French as the only allowed language.
- Log in as user A and visit the list of the node's translation.
- The edit link next to the French translation follows to the translation form, which shows 403 Access Denied to this user. Same is for the deletion link.
- However, you're still able to view the translation and then edit it through the local task.
The Allowed Languages module just implements a language-dependent access check that triggers the bug, the same could be achieved with a custom module. It also provides a route access check, but even with the allowed_languages.content_translation_access_check service removed, the issue is still reproducible.
Proposed resolution
Perform the access check on an entity translation in the content translation overview.
Remaining tasks
- Submit MR.
- Write release notes snippet.
User interface changes
No.
API changes
No.
Data model changes
No.
Release notes snippet
TODO
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 3257030-4.diff | 9.87 KB | dmitriy.trt |
| #2 | tests_only-3257030-2.patch | 7.87 KB | dmitriy.trt |
Issue fork drupal-3257030
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:
- 3257030-inconsistent-access-check
changes, plain diff MR !1611
Comments
Comment #2
dmitriy.trt commentedThe attached patch contains tests only, to make sure they fail without actual changes.
Comment #4
dmitriy.trt commentedAttaching a patch that was made from MR!1611 at commit
92afcb78for a stable reference from Composer.Comment #6
recrit commentedThanks for the patch. I ran into this access check oddity too when attempting to add some access rules for translations.
I would expect that the "create" access call should get the same updates as in this patch, so that the creation of specific translations could be restricted as well.
However, the translation entity cannot be created at that time so we would need to pass the language or just the language code.
Comment #8
balagan commentedI confirm that applying the patch in #4 solves the problem. Edit/Delete operation buttons only display for eligible translations.
Comment #11
quietone commentedWork done by longwave using an LLM that identified this as a duplicate of #3371291: Content translation "update" and "delete" entity operation access checks are not made on the correct entity translation and suggested closing that one. After reading both issue I choose to close this one, so the new patch in the other issue is used. I've updated the issue summary over there with a task to get the test from the patch here.