Automatically closed - issue fixed for 2 weeks with no activity.
When rendering a pattern, Patternkit uses a pattern's Twig template content to render the markup and this requires compiling the Twig files producing cache files in the site's file cache directory (typically located at sites/default/files/php/twig/
). The way template content is loaded and cached in the database rather than loading directly from the file produces every pattern's primary template output as a string template compilation file rather than directly mapped to the pattern's twig file. This implementation for rendering is used for every pattern using the Twig plugin and may be seen here:
$template = $pattern->getTemplate();
if (empty($template)) {
return [];
}
$pattern->config ??= [];
$output = [
'#type' => 'inline_template',
'#template' => $template,
'#context' => $pattern->config,
];
Additionally, the current implementation of Token processing is using a PatternFieldProcessor plugin implementation to recursively iterate through all string properties and replace token values into the string. Unfortunately, this implementation attempts to support Twig filters on token values in the string and in doing so renders every string value as a compiled Twig cache file for every field value it encounters. This means a new string template Twig cache file is created for every unique string value in any field of any pattern instance.
<!--break-->Confirmation of this behavior requires default Twig caching behaviors to be enabled and access to review file creation within the site's files directory.
/devel/pattern-test
drush cr
) or delete all compiled Twig files within sites/default/files/php/twig
{
"text": "text value",
"formatted_text": "<strong>My formatted text</strong>"
}
sites/default/files/php/twig
folderSince the support for Twig filters on token values in patterns is undocumented and likely sees very limited use, I propose removing support for this functionality and simplifying the token processor to only replace token values into the string without the twig rendering process. This will remove the inline template rendering for dynamic string values (a violation of best practice), and should resolve the creation of new twig cache files for every new string value encountered.
None
None
Fixed
9.1
Module Core
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
Automatically closed - issue fixed for 2 weeks with no activity.