Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Merge requests
!1609
Issue
#3256906
avoid translation access checks
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
Issue
#3256906
avoid translation access checks
issue/drupal-3256906:3256906-avoid-translation-access-checks
into
9.3.x
Overview
0
Commits
2
Pipelines
0
Changes
1
Open
Beatriz Rodrigues
requested to merge
issue/drupal-3256906:3256906-avoid-translation-access-checks
into
9.3.x
3 years ago
Overview
0
Commits
2
Pipelines
0
Changes
1
Expand
Closes
#3256906
Edited
3 years ago
by
Beatriz Rodrigues
0
0
Merge request reports
Compare
9.3.x
version 2
90cf561d
3 years ago
version 1
90cf561d
3 years ago
9.3.x (HEAD)
and
latest version
latest version
fb41b89f
2 commits,
3 years ago
version 2
90cf561d
1 commit,
3 years ago
version 1
90cf561d
120 commits,
3 years ago
1 file
+
12
−
11
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
core/modules/content_translation/content_translation.module
+
12
−
11
Options
@@ -439,19 +439,20 @@ function content_translation_language_fallback_candidates_entity_view_alter(&$ca
/** @var \Drupal\content_translation\ContentTranslationHandlerInterface $handler */
$handler
=
\Drupal
::
entityTypeManager
()
->
getHandler
(
$entity
->
getEntityTypeId
(),
'translation'
);
foreach
(
$entity
->
getTranslationLanguages
()
as
$langcode
=>
$language
)
{
$metadata
=
$manager
->
getTranslationMetadata
(
$entity
->
getTranslation
(
$langcode
));
if
(
!
$metadata
->
isPublished
())
{
$access
=
$handler
->
getTranslationAccess
(
$entity
,
'update'
);
$entity
->
addCacheableDependency
(
$access
);
if
(
!
$access
->
isAllowed
())
{
// If the user has no translation update access, also check view
// access for that translation, to allow other modules to allow access
// to unpublished translations.
$access
=
$entity
->
getTranslation
(
$langcode
)
->
access
(
'view'
,
NULL
,
TRUE
);
if
(
in_array
(
$langcode
,
$candidates
))
{
$metadata
=
$manager
->
getTranslationMetadata
(
$entity
->
getTranslation
(
$langcode
));
if
(
!
$metadata
->
isPublished
())
{
$access
=
$handler
->
getTranslationAccess
(
$entity
,
'update'
);
$entity
->
addCacheableDependency
(
$access
);
if
(
!
$access
->
isAllowed
())
{
unset
(
$candidates
[
$langcode
]);
// If the user has no translation update access, also check view
// access for that translation, to allow other modules to allow access
// to unpublished translations.
$access
=
$entity
->
getTranslation
(
$langcode
)
->
access
(
'view'
,
NULL
,
TRUE
);
$entity
->
addCacheableDependency
(
$access
);
if
(
!
$access
->
isAllowed
())
{
unset
(
$candidates
[
$langcode
]);
}
}
}
}
Loading