Commit d7a82b5b authored by catch's avatar catch
Browse files

Issue #3265362 by quietone, dww, murilohp: Do not display obsolete themes at admin/appearance

parent 2b1faaac
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -209,4 +209,17 @@ public function isExperimental(): bool {
        && $this->info[ExtensionLifecycle::LIFECYCLE_IDENTIFIER] === ExtensionLifecycle::EXPERIMENTAL);
  }

  /**
   * Checks if an extension is marked as obsolete.
   *
   * @return bool
   *   TRUE if an extension is marked as obsolete, FALSE otherwise.
   */
  public function isObsolete(): bool {
    // This function checks for 'lifecycle: obsolete' to determine if an
    // extension is marked as obsolete.
    return (isset($this->info[ExtensionLifecycle::LIFECYCLE_IDENTIFIER])
        && $this->info[ExtensionLifecycle::LIFECYCLE_IDENTIFIER] === ExtensionLifecycle::OBSOLETE);
  }

}
+6 −1
Original line number Diff line number Diff line
@@ -191,7 +191,7 @@ public function systemAdminMenuBlockPage() {
  }

  /**
   * Returns a theme listing.
   * Returns a theme listing which excludes obsolete themes.
   *
   * @return string
   *   An HTML string of the theme listing page.
@@ -202,6 +202,11 @@ public function themesPage() {
    $config = $this->config('system.theme');
    // Get all available themes.
    $themes = $this->themeHandler->rebuildThemeData();

    // Remove obsolete themes.
    $themes = array_filter($themes, function ($theme) {
      return !$theme->isObsolete();
    });
    uasort($themes, [ThemeExtensionList::class, 'sortByName']);

    $theme_default = $config->get('default');
+4 −0
Original line number Diff line number Diff line
@@ -320,6 +320,10 @@ public function testAdministrationTheme() {
    $this->drupalGet('admin/appearance');
    $this->submitForm($edit, 'Save configuration');

    // Check that obsolete themes are not displayed.
    $this->drupalGet('admin/appearance');
    $this->assertSession()->pageTextNotContains('Obsolete test theme');

    // Check that the administration theme is used on an administration page.
    $this->drupalGet('admin/config');
    $this->assertSession()->responseContains('core/themes/seven');
+7 −0
Original line number Diff line number Diff line
name: 'Obsolete theme test'
type: theme
description: 'Obsolete test theme.'
version: VERSION
lifecycle: obsolete
lifecycle_link: 'https://example.com/obsolete'
base theme: false