Skip to content
Snippets Groups Projects
Commit ec7c5ca6 authored by catch's avatar catch
Browse files

Issue #3509565 by kristiaanvandeneynde:...

Issue #3509565 by kristiaanvandeneynde: ConfigTranslationController::itemPage() does not specify cacheable metadata
parent ee78cfa7
No related branches found
No related tags found
2 merge requests!11983Issue #3521857 by jwilson3: Update file type icons to use SVG,!2964Issue #2865710 : Dependencies from only one instance of a widget are used in display modes
Pipeline #440955 passed with warnings
Pipeline: drupal

#440969

    Pipeline: drupal

    #440960

      Pipeline: drupal

      #440957

        ......@@ -6,6 +6,7 @@
        use Drupal\config_translation\ConfigMapperManagerInterface;
        use Drupal\config_translation\Exception\ConfigMapperLanguageException;
        use Drupal\Core\Access\AccessManagerInterface;
        use Drupal\Core\Cache\CacheableMetadata;
        use Drupal\Core\Controller\ControllerBase;
        use Drupal\Core\Language\Language;
        use Drupal\Core\Language\LanguageInterface;
        ......@@ -131,6 +132,8 @@ public static function create(ContainerInterface $container) {
        * Page render array.
        */
        public function itemPage(Request $request, RouteMatchInterface $route_match, $plugin_id) {
        $cacheable_metadata = new CacheableMetadata();
        /** @var \Drupal\config_translation\ConfigMapperInterface $mapper */
        $mapper = $this->configMapperManager->createInstance($plugin_id);
        $mapper->populateFromRouteMatch($route_match);
        ......@@ -204,11 +207,12 @@ public function itemPage(Request $request, RouteMatchInterface $route_match, $pl
        // Check access for the path/route for editing, so we can decide to
        // include a link to edit or not.
        $edit_access = $this->accessManager->checkNamedRoute($mapper->getBaseRouteName(), $route_match->getRawParameters()->all(), $this->account);
        $edit_access = $this->accessManager->checkNamedRoute($mapper->getBaseRouteName(), $route_match->getRawParameters()->all(), $this->account, TRUE);
        $cacheable_metadata->addCacheableDependency($edit_access);
        // Build list of operations.
        $operations = [];
        if ($edit_access) {
        if ($edit_access->isAllowed()) {
        $operations['edit'] = [
        'title' => $this->t('Edit'),
        'url' => Url::fromRoute($mapper->getBaseRouteName(), $mapper->getBaseRouteParameters(), ['query' => ['destination' => $mapper->getOverviewPath()]]),
        ......@@ -218,6 +222,14 @@ public function itemPage(Request $request, RouteMatchInterface $route_match, $pl
        else {
        $language_name = $language->getName();
        // The translation check below might change if the configs change, so we
        // need to add their cache tags.
        $cache_tags = [];
        foreach ($mapper->getConfigNames() as $configName) {
        $cache_tags[] = "config:$configName";
        }
        $cacheable_metadata->addCacheTags($cache_tags);
        $operations = [];
        // If no translation exists for this language, link to add one.
        if (!$mapper->hasTranslation($language)) {
        ......@@ -274,6 +286,7 @@ public function itemPage(Request $request, RouteMatchInterface $route_match, $pl
        '#attached' => ['library' => ['core/drupal.dialog.ajax']],
        ];
        }
        $cacheable_metadata->applyTo($page);
        return $page;
        }
        ......
        ......@@ -392,9 +392,8 @@ public function testNodeFieldTranslation(): void {
        'entity_type' => 'node',
        'type' => 'text',
        ]);
        $field_storage->setSetting('translatable_storage_setting', 'translatable_storage_setting');
        $field_storage->save();
        $field = FieldConfig::create([
        'field_name' => $field_name,
        'entity_type' => 'node',
        ......
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Please register or to comment