Verified Commit d5fc1a8f authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #2958649 by acbramley, moshe weitzman, fenstrat: Incorrect totals count...

Issue #2958649 by acbramley, moshe weitzman, fenstrat: Incorrect totals count when importing config that contains a theme uninstall

(cherry picked from commit 3761dff8)
parent 9a4c8b08
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -630,6 +630,12 @@ protected function processConfigurations(&$context) {
          $this->totalConfigurationToProcess += count($this->getUnprocessedConfiguration($op, $collection));
        }
      }

      // Adjust the totals for system.theme.
      // @see \Drupal\Core\Config\ConfigImporter::processExtension
      if ($this->processedSystemTheme) {
        $this->totalConfigurationToProcess++;
      }
    }
    $operation = $this->getNextConfigurationOperation();
    if (!empty($operation)) {
+42 −0
Original line number Diff line number Diff line
@@ -858,6 +858,48 @@ public function testCustomStep() {
    $this->assertFalse(\Drupal::isConfigSyncing(), 'After an valid custom step \Drupal::isConfigSyncing() returns FALSE');
  }

  /**
   * Tests that uninstall a theme in config import correctly imports all config.
   */
  public function testUninstallThemeIncrementsCount(): void {
    $theme_installer = $this->container->get('theme_installer');
    // Install our theme.
    $theme = 'test_basetheme';
    $theme_installer->install([$theme]);

    $this->assertTrue($this->container->get('theme_handler')->themeExists($theme));

    $sync = $this->container->get('config.storage.sync');

    // Update 2 pieces of config in sync.
    $systemSiteName = 'system.site';
    $system = $sync->read($systemSiteName);
    $system['name'] = 'Foo';
    $sync->write($systemSiteName, $system);

    $cronName = 'system.cron';
    $cron = $sync->read($cronName);
    $this->assertEquals(1, $cron['logging']);
    $cron['logging'] = 0;
    $sync->write($cronName, $cron);

    // Uninstall the theme in sync.
    $extensions = $sync->read('core.extension');
    unset($extensions['theme'][$theme]);
    $sync->write('core.extension', $extensions);

    $this->configImporter()->import();

    // The theme should be uninstalled.
    $this->assertFalse($this->container->get('theme_handler')->themeExists($theme));

    // Both pieces of config should be updated.
    \Drupal::configFactory()->reset($systemSiteName);
    \Drupal::configFactory()->reset($cronName);
    $this->assertEquals('Foo', $this->config($systemSiteName)->get('name'));
    $this->assertEquals(0, $this->config($cronName)->get('logging'));
  }

  /**
   * Helper method to test custom config installer steps.
   *