Skip to content
Snippets Groups Projects

Issue #3256906 avoid translation access checks

@@ -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