diff -u b/core/includes/theme.inc b/core/includes/theme.inc --- b/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -316,11 +316,12 @@ // If _theme() was invoked with a direct theme suggestion like // '#theme' => 'node__article', add it to the suggestions array before // invoking suggestion alter hooks. - if (isset($info['base hook'])) { - $suggestions[] = $hook; - } if ($hook != $theme_hooks) { $suggestions = array_merge($suggestions, (array) $theme_hooks); + $suggestions = array_reverse($suggestions); + } + if (isset($info['base hook'])) { + $suggestions[] = $hook; } // Invoke hook_theme_suggestions_alter() and diff -u b/core/themes/engines/twig/twig.engine b/core/themes/engines/twig/twig.engine --- b/core/themes/engines/twig/twig.engine +++ b/core/themes/engines/twig/twig.engine @@ -88,12 +88,12 @@ $extension = twig_extension(); $current_template = basename($template_file); $suggestions = $variables['theme_hook_suggestions']; - $suggestions = array_unique($suggestions); // Only add the original theme hook if it wasn't a directly called // suggestion. if (strpos($variables['theme_hook_original'], '__') === FALSE) { $suggestions[] = $variables['theme_hook_original']; } + $suggestions = array_unique($suggestions); foreach ($suggestions as &$suggestion) { $template = strtr($suggestion, '_', '-') . $extension; $prefix = ($template == $current_template) ? 'x' : '*';