Verified Commit 01b19986 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2898274 by aleevas, piotrkonefal, borisson_, GaëlG, ankithashetty,...

Issue #2898274 by aleevas, piotrkonefal, borisson_, GaëlG, ankithashetty, dietr_ch, robpowell, alexpott: Uninstalled custom theme stuck in config blocking config import

(cherry picked from commit bfc5c6d1)
parent 29878758
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -266,7 +266,7 @@ public function uninstall(array $theme_list) {
    $theme_config = $this->configFactory->getEditable('system.theme');
    $list = $this->themeHandler->listInfo();
    foreach ($theme_list as $key) {
      if (!isset($list[$key])) {
      if ($extension_config->get("theme.$key") === NULL) {
        throw new UnknownExtensionException("Unknown theme: $key.");
      }
      if ($key === $theme_config->get('default')) {
@@ -277,7 +277,7 @@ public function uninstall(array $theme_list) {
      }
      // Base themes cannot be uninstalled if sub themes are installed, and if
      // they are not uninstalled at the same time.
      if (!empty($list[$key]->sub_themes)) {
      if (isset($list[$key]) && !empty($list[$key]->sub_themes)) {
        foreach ($list[$key]->sub_themes as $sub_key => $sub_label) {
          if (isset($list[$sub_key]) && !in_array($sub_key, $theme_list, TRUE)) {
            throw new \InvalidArgumentException("The base theme $key cannot be uninstalled, because theme $sub_key depends on it.");
+4 −3
Original line number Diff line number Diff line
@@ -41,12 +41,13 @@ public function install(array $theme_list, $install_dependencies = TRUE);
   * Uninstalling a theme removes all related configuration (like blocks) and
   * invokes the 'themes_uninstalled' hook.
   *
   * Themes are allowed to be uninstalled even when their code has been removed
   * from the filesystem, this is because themes do not allow uninstall hooks to
   * be defined.
   *
   * @param array $theme_list
   *   The themes to uninstall.
   *
   * @throws \Drupal\Core\Extension\Exception\UnknownExtensionException
   *   Thrown when trying to uninstall a theme that was not installed.
   *
   * @throws \InvalidArgumentException
   *   Thrown when trying to uninstall the admin theme, the default theme or
   *   a theme that another theme depends on.
+6 −19
Original line number Diff line number Diff line
@@ -355,17 +355,8 @@ public function testUninstallNonExisting() {
    $themes = $this->themeHandler()->listInfo();
    $this->assertEmpty(array_keys($themes));

    try {
      $message = 'ThemeInstaller::uninstall() throws UnknownExtensionException upon uninstalling a non-existing theme.';
    $this->expectException(UnknownExtensionException::class);
    $this->themeInstaller()->uninstall([$name]);
      $this->fail($message);
    }
    catch (\Exception $e) {
      $this->assertInstanceOf(UnknownExtensionException::class, $e);
    }

    $themes = $this->themeHandler()->listInfo();
    $this->assertEmpty(array_keys($themes));
  }

  /**
@@ -397,14 +388,10 @@ public function testUninstall() {
  public function testUninstallNotInstalled() {
    $name = 'test_basetheme';

    try {
      $message = 'ThemeInstaller::uninstall() throws UnknownExtensionException upon uninstalling a theme that is not installed.';
    $themes = $this->themeHandler()->listInfo();
    $this->assertEmpty(array_keys($themes));
    $this->expectException(UnknownExtensionException::class);
    $this->themeInstaller()->uninstall([$name]);
      $this->fail($message);
    }
    catch (\Exception $e) {
      $this->assertInstanceOf(UnknownExtensionException::class, $e);
    }
  }

  /**