Loading core/lib/Drupal/Core/Config/ConfigImporter.php +3 −0 Original line number Diff line number Diff line Loading @@ -927,6 +927,9 @@ protected function processExtension(string $type, string $op, string|array $name $this->processedSystemTheme = TRUE; } \Drupal::service('theme_installer')->$op($names); // Installing a theme can also cause a kernel boot, so re-inject services // as is done with modules. $this->reInjectMe(); } $this->setProcessedExtension($type, $op, $names); } Loading core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php +25 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ use Drupal\Core\Config\ConfigEvents; use Drupal\Core\Config\ConfigImporter; use Drupal\Core\Config\ConfigImporterException; use Drupal\Core\Extension\ThemeHandlerInterface; use Drupal\KernelTests\KernelTestBase; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses; Loading Loading @@ -948,6 +949,30 @@ public function testUninstallThemeIncrementsCount(): void { $this->assertEquals(0, $this->config($cronName)->get('logging')); } /** * Tests that installing a theme will reload all service dependencies. */ public function testThemeInstallReloadsServices(): void { $this->assertFalse(\Drupal::service(ThemeHandlerInterface::class)->themeExists('test_base_theme')); $sync = $this->container->get('config.storage.sync'); // Ensure that the config import will install the theme. $extensions = $sync->read('core.extension'); $extensions['theme']['test_base_theme'] = 0; $sync->write('core.extension', $extensions); $importer = $this->configImporter(); $property = new \ReflectionProperty($importer, 'themeHandler'); $old_theme_handler = $property->getValue($importer); $this->assertIsObject($old_theme_handler); $importer->import(); $this->assertTrue(\Drupal::service(ThemeHandlerInterface::class)->themeExists('test_base_theme')); $new_theme_handler = $property->getValue($importer); $this->assertIsObject($new_theme_handler); $this->assertNotSame($old_theme_handler, $new_theme_handler); } /** * Tests config events during config import. */ Loading Loading
core/lib/Drupal/Core/Config/ConfigImporter.php +3 −0 Original line number Diff line number Diff line Loading @@ -927,6 +927,9 @@ protected function processExtension(string $type, string $op, string|array $name $this->processedSystemTheme = TRUE; } \Drupal::service('theme_installer')->$op($names); // Installing a theme can also cause a kernel boot, so re-inject services // as is done with modules. $this->reInjectMe(); } $this->setProcessedExtension($type, $op, $names); } Loading
core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php +25 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ use Drupal\Core\Config\ConfigEvents; use Drupal\Core\Config\ConfigImporter; use Drupal\Core\Config\ConfigImporterException; use Drupal\Core\Extension\ThemeHandlerInterface; use Drupal\KernelTests\KernelTestBase; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses; Loading Loading @@ -948,6 +949,30 @@ public function testUninstallThemeIncrementsCount(): void { $this->assertEquals(0, $this->config($cronName)->get('logging')); } /** * Tests that installing a theme will reload all service dependencies. */ public function testThemeInstallReloadsServices(): void { $this->assertFalse(\Drupal::service(ThemeHandlerInterface::class)->themeExists('test_base_theme')); $sync = $this->container->get('config.storage.sync'); // Ensure that the config import will install the theme. $extensions = $sync->read('core.extension'); $extensions['theme']['test_base_theme'] = 0; $sync->write('core.extension', $extensions); $importer = $this->configImporter(); $property = new \ReflectionProperty($importer, 'themeHandler'); $old_theme_handler = $property->getValue($importer); $this->assertIsObject($old_theme_handler); $importer->import(); $this->assertTrue(\Drupal::service(ThemeHandlerInterface::class)->themeExists('test_base_theme')); $new_theme_handler = $property->getValue($importer); $this->assertIsObject($new_theme_handler); $this->assertNotSame($old_theme_handler, $new_theme_handler); } /** * Tests config events during config import. */ Loading