Problem/Motivation
drush bs-tc (BsLibCommands::themeCreate()) builds the child theme's .info.yml in BsLibCommands::generateFile() from the parent theme's info array. It removes libraries-extend and component-libraries, but it keeps the components key, which is where Components 3.x reads Twig namespaces:
components: namespaces: atoms: - components/_patterns/01-atoms molecules: - components/_patterns/02-molecules organisms: - components/_patterns/03-organisms
The paths are relative to the theme that declares them. The child theme does not get a components/ folder (copyThemeFiles() does not copy it), so every path points to a folder that does not exist. On every cache rebuild Components logs one warning per namespace from ComponentsRegistry::load():
The "@organisms" namespace contains a path, "themes/custom/design/components/_patterns/03-organisms", that is not a directory.The copied key is not new: child themes created with bs-tc have carried it for a long time. It only shows up now because of the Components version. Components 8.x-2.x skips a namespace path that is not a directory without a message, so sites on 2.x have the same copied block and an empty log. Components 3.x logs the warning above, so the problem becomes visible when a site updates to Components 3.x.
The copied key is also not needed. ComponentsRegistry::findNamespaces() merges the namespaces of all base themes into the active theme, so templates in the parent's namespaces resolve in the child theme without the child declaring them.
Steps to reproduce
- Install the Components module (3.x) and a bs_base based theme whose
.info.ymlhascomponents: namespaces:with relative paths (for example a theme with Pattern Lab folders undercomponents/_patterns/). - Run
drush bs-tc <parent> mytheme "My theme" "My theme"and enablemythemeas the default theme. - Run
drush crand open any page. - The log has one "namespace contains a path ... that is not a directory" warning per namespace, for paths under
themes/custom/mytheme/components/.
Proposed resolution
In BsLibCommands::generateFile(), remove the components key together with component-libraries:
// Remove libraries-extend and the Components module namespaces. The // namespace paths are relative to the parent theme, and Components // already gives a sub-theme the namespaces of its base themes. unset($yaml_array['libraries-extend']); unset($yaml_array['component-libraries']); unset($yaml_array['components']);
A child theme that later adds its own components folder declares its own namespaces.
Remaining tasks
- Patch.
- Decide whether existing child themes need a
bs_updatehook that removescomponentspaths that do not exist in the child theme, or only a note in the release notes.
User interface changes
None.
API changes
None.
Data model changes
None.
Issue fork bs_lib-3628921
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
pivica commentedDone.