Locales are not being translated after a cache rebuild with untranslated url fields

Created on 6 August 2020, over 4 years ago
Updated 20 October 2023, about 1 year ago

Problem/Motivation

After a cache rebuild, locale translations are not being rendered on the template containing the query with e.g. a fieldLink.
Not sure yet what is causing the issue but starting to describe it here.

  • Vanilla core 8.9.2 with content translation and interface translation
  • Default language detection

Steps to reproduce

  • Add a Link field to a node type (e.g. Article)
  • Populate the link for a node
  • On a template override e.g. node--article.html.twig, add this query
{#graphql
query ($node: String!) {
  node:nodeById(id: $node) {
    entityLabel
    ... on NodeArticle {
      title
      fieldLink {
        title
        url {
          path
        }
      }
    }
  }
}
#}
  • add a string (locale) to the template {{ 'Translation'|t }}
  • translate the locale in FR
  • display the node with the interface in FR (/fr/node/1)

Observations

  • With the string displayed in the source (e.g. EN)
  • If the string is updated via the UI /admin/config/regional/translate it triggers $this->cacheTagsInvalidator->invalidateTags(['rendered', 'locale']);
  • Then after a page reload, the string is translated in FR
  • On cache rebuild, the locale is the source (EN) again
  • The tags invalidation is only fine when the template has been rendered at least one time with the source locale (so a workaround with e.g. hook_rebuild() won't work)
  • The issue is not met while removing the url { path } from the query or not having a value for the link
  • A parent template (e.g. page.html.twig) with the same locale is translated properly
🐛 Bug report
Status

Active

Version

3.0

Component

Code

Created by

🇨🇭Switzerland colorfield Lausanne

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024