Verified Commit 528ac574 authored by Dave Long's avatar Dave Long
Browse files

Issue #3073053 by pivica, Primsi, unstatu, pooja saraah, smustgrave, Berdir:...

Issue #3073053 by pivica, Primsi, unstatu, pooja saraah, smustgrave, Berdir: Theme library override can fail in when you have multiple parent themes
parent 30512d2e
Loading
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -183,7 +183,8 @@ public function getLibraries() {
   * Returns an array of base theme extension objects keyed by name.
   *
   * The order starts with the base theme of $this and ends with the root of
   * the dependency chain.
   * the dependency chain. For most use cases, parent themes are expected to
   * be called first, so this order needs to be reversed with array_reverse()
   *
   * @return \Drupal\Core\Extension\Extension[]
   */
+3 −3
Original line number Diff line number Diff line
@@ -131,14 +131,14 @@ public function loadActiveTheme(ActiveTheme $active_theme) {
    if ($active_theme->getEngine()) {
      // Include the engine.
      include_once $this->root . '/' . $active_theme->getOwner();
      foreach ($active_theme->getBaseThemeExtensions() as $base) {
      foreach (array_reverse($active_theme->getBaseThemeExtensions()) as $base) {
        $base->load();
      }
      $active_theme->getExtension()->load();
    }
    else {
      // include non-engine theme files
      foreach ($active_theme->getBaseThemeExtensions() as $base) {
      foreach (array_reverse($active_theme->getBaseThemeExtensions()) as $base) {
        // Include the theme file or the engine.
        if ($base->owner) {
          include_once $this->root . '/' . $base->owner;
@@ -178,7 +178,7 @@ public function getActiveTheme(Extension $theme, array $base_themes = []) {
    $values['libraries_override'] = [];

    // Get libraries overrides declared by base themes.
    foreach ($base_themes as $base) {
    foreach (array_reverse($base_themes) as $base) {
      if (!empty($base->info['libraries-override'])) {
        foreach ($base->info['libraries-override'] as $library => $override) {
          $values['libraries_override'][$base->getPath()][$library] = $override;
+1 −1
Original line number Diff line number Diff line
@@ -436,7 +436,7 @@ public function alterForTheme(ActiveTheme $theme, $type, &$data, &$context1 = NU
      }
    }

    $theme_keys = array_keys($theme->getBaseThemeExtensions());
    $theme_keys = array_reverse(array_keys($theme->getBaseThemeExtensions()));
    $theme_keys[] = $theme->getName();
    $functions = [];
    foreach ($theme_keys as $theme_key) {
+5 −0
Original line number Diff line number Diff line
@@ -3,3 +3,8 @@ type: theme
description: 'Test theme which uses test_subtheme as the base theme.'
version: VERSION
base theme: test_subtheme
libraries-override:
  test_basetheme/global-styling:
    css:
      base:
        css/sub-sub-last-override.css: false
+1 −1
Original line number Diff line number Diff line
@@ -1485,7 +1485,7 @@ public function render($display_id = NULL) {
    // @todo In the long run, it would be great to execute a view without
    //   the theme system at all. See https://www.drupal.org/node/2322623.
    $active_theme = \Drupal::theme()->getActiveTheme();
    $themes = array_keys($active_theme->getBaseThemeExtensions());
    $themes = array_reverse(array_keys($active_theme->getBaseThemeExtensions()));
    $themes[] = $active_theme->getName();

    // Check for already-cached output.
Loading