- Issue created by @codebymikey
The following exception is thrown after enabling a new subtheme in Drupal 10.2:
Twig\Error\LoaderError: Template "@namespace/path/template-name.html.twig" is not defined
This is because the code relies on the cache being invalidated by the theme_registry
tag. However the commit from
📌
Manually clear cache keys from plugin managers with finite variations instead of using cache tags
Fixed
means that the cache is never invalidated, and newly enabled themes will always be set to an empty array rather than built using the findNamespaces
method.
Enable a new child theme that extends a parent theme making use of components. Going to a page making use of that component template will trigger a crash when using the child theme.
Add more cache tags, and explicitly clear the components cache ourselves via a hook like:
/**
* Implements hook_themes_installed().
*/
function components_themes_installed($theme_list) {
// Clear the cached namespaces components whenever a new theme is
// installed.
Cache::invalidateTags(['components_namespaces']);
}
Or just as easily, always attempt to find a namespace if it doesn't exist in the cache.
Provide issue fork.
N/A
N/A
Active
3.0
Code