Needs work
Project:
Drupal core
Version:
main
Component:
content_translation.module
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
13 Jul 2018 at 17:45 UTC
Updated:
17 Apr 2026 at 18:19 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
christian.wiedemann commentedThe patch moves translation access logic to an own translation_access handler (ContentTranslationAccessControlHandler ) and makes it easy to allow modules to check per-entity if it is allowed to create/update/delete an entity translation. Maybe we should add an EntityValidation Handler to validate on save .
The $context for createAccess contains the translation language as langcode and the entity as source_entity.
I marked getTranslationAccess() as deprecated. Hope this points into the right direction.
Comment #3
christian.wiedemann commentedNow with correct root folder
Comment #4
andypostComment #5
berdirHave you seen the discussion in the related issue?
I don't see how there can be a difference between the existing access checks for update/delete *if* we ensure that the entity is passed in in the right language.
The create access on the other hand is different, there we need additional information (the language, not sure what else, the entity type id is not needed, you can get that from the entity)
My suggestion would be to limit this issue to create access only, like the issue title says, and leave it to the referenced issue to figure out how to dea with update/delete.
Comment #6
christian.wiedemann commentedSorry now i get it and you are completly right. It does not make sense to have own checks for update/delete
Maybe we don't need them for create either. Simple call the EntityAccessControlHandler::createAccess and simple provide the "source translation entity id" as $context parameter inside the overview controller. Lancode is already a context parameter.
(Would need another patch to handle the static cache correctly inside EntityAccessControlHandler)
Another option would be to move access logic to an own handler (ContentTranslationAccessControlHandler with createTranslationAccess and getTranslationAccess)
In both cases we must call the check also "before save" because only than we have the correct language.
What do you think?
Comment #8
matthiasm11 commented#3018576: Content translation should allow for a language-aware access checks deprecates getTranslationAccess() which means this issue can't make it into core if so.
Please use #3056020: Content translation access control to agree on an implementation plan.
Comment #16
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #19
hchonovI came up with the following idea where I add to
\Drupal\content_translation\ContentTranslationHandler::getTranslationAccess()an entity_access hook invocation by prepending the operation with "translation_" e.g. becoming "tranlation_create", "translation_update", "translation_delete" and also passing additional\$contextvariable with the source and target language in the case of "translation_create".One of the major changes here is that
\Drupal\content_translation\Access\ContentTranslationManageAccessCheck::access()does not anymore return early if the user has the permissiontranslate any entity, but makes sure that all other checks are executed first including the hooks, that could forbid access. It now instead relies on\Drupal\content_translation\ContentTranslationHandler::getTranslationAccess()to check that permission, as it already does anyway.Patch is pretty rough only as an idea and based on 10.5 since I need once again a similar solution.
Comment #20
hchonovI've forgotten to add the context at one place.
Comment #21
hchonovEdge case fix when there are no translations yet.
Comment #22
hchonovComment #23
smustgrave commentedHave not reviewed but changes should be in MRs please