For the last two days I have been trying to discover the reason for a strange bug in a custom theme that I am currently developing.
Basically, I created a subtheme of a subtheme that simply wouldn't allow me to "install" it: I always got the "theme was not found" error message, although the theme appeared to be there and all required files were present. (Similar to what is described
here →
, but not restricted to Install and set default
, but also appearing on hitting Install
.)
I found out how to circumvent this bug only by investigating the code in ThemeInstaller.php: Turns out the reason for this was a dependency that I had set on the parent theme (using the feature introduced
here →
): When I removed this dependency, the subtheme could be installed without problems.
Steps for reproducing the bug:
- Create a simple theme parent (can be a subtheme of another theme) and declare a dependency on some module in parent.info.yml.
- Create a simple subtheme child of theme parent with only a basic setup in child.info.yml.
- Click
Install
on the /admin/appearancepage.
This results in an error message: "The child theme was not found." I haven't done a through investigation, but I think, this is caused at this point in ThemeInstaller.php:
foreach (array_keys($theme_data[$theme]->requires) as $dependency) {
if (!isset($theme_data[$dependency])) {
// The dependency does not exist.
return FALSE;
}
// Skip already installed themes.
if (!isset($theme_list[$dependency]) && !isset($installed_themes[$dependency])) {
$theme_list[$dependency] = $dependency;
}
}