Closed (fixed)
Project:
Entity Registry
Version:
1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
21 Aug 2026 at 12:50 UTC
Updated:
8 Sep 2026 at 12:45 UTC
Jump to comment: Most recent
We are recibing multiples errors related to theme hooks, like "Theme hook responsive_image_formatter not found." The problem occurs when an editor saves a node and the synchronous option is enabled, the module performs a theme switch but does not restart the registry, so the old admin theme registry is kept, and the errors are registered.
EntityRenderContext::renderEntity()
$previousTheme = $theme !== NULL
? $this->themeSwitcher->switchTo($theme)
: $this->themeSwitcher->switchToDefault();
ThemeSwitcher.php
public function switchToDefault(): ?ActiveTheme {
$defaultTheme = $this->configFactory
->get('system.theme')
->get('default'); // = Main site theme.
return $this->switchTo($defaultTheme);
}
public function switchTo(string $themeName): ?ActiveTheme {
$activeTheme = $this->themeManager->getActiveTheme();
// If the default theme is the same as the switched theme, it returns NULL, but the active theme is the admin one.
if ($themeName === $activeTheme->getName()) {
return NULL; // <-- CLAVE
}
// Here changes the theme.
$newTheme = $this->themeInitializer->getActiveThemeByName($themeName);
$this->themeManager->setActiveTheme($newTheme);
drupal_static_reset('template_preprocess');
return $activeTheme;
}
The error comes from ThemeManager::render()
$active_theme = $this->getActiveTheme(); // New active theme.
$theme_registry = $this->themeRegistry->getRuntime(); // Old registry theme (admin one).
if (!$theme_registry->has($hook)) {
while ($pos = strrpos($hook, '__')) { ... } // try to get theme hooks that are registered by admin theme, but no available on main theme.
if (!$theme_registry->has($hook)) {
if (!isset($candidate)) {
\Drupal::logger('theme')->warning('Theme hook %hook not found.', ['%hook' => $hook]);
}
return FALSE;
}
}
Process the item on the destruct, same strategy as search_api
search_api.post_request_indexing:
class: Drupal\search_api\Utility\PostRequestIndexing
tags:
- { name: needs_destruction }
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 #3
eduardo morales albertiComment #4
eduardo morales albertiReady to review
Comment #6
eduardo morales albertiMerged