From 3304901ac256c7a1968f4df78c1008403b9e0c10 Mon Sep 17 00:00:00 2001 From: catch <catch@35733.no-reply.drupal.org> Date: Thu, 19 Mar 2020 20:08:21 +0000 Subject: [PATCH] Issue #3119373 by alexpott, BramDriesen: Configuration synchronisation that both enables & configures a module fails and drupal_flush_all_caches() --- core/includes/common.inc | 5 ++- .../Core/Common/DrupalFlushAllCachesTest.php | 32 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 core/tests/Drupal/KernelTests/Core/Common/DrupalFlushAllCachesTest.php diff --git a/core/includes/common.inc b/core/includes/common.inc index b6582df851de..19773320dba6 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -550,12 +550,15 @@ function drupal_flush_all_caches() { // sufficient, since the list of enabled modules might have been adjusted // above due to changed code. $files = []; + $modules = []; foreach ($module_data as $name => $extension) { if ($extension->status) { $files[$name] = $extension; + $modules[$name] = $extension->weight; } } - \Drupal::service('kernel')->updateModules($module_handler->getModuleList(), $files); + $modules = module_config_sort($modules); + \Drupal::service('kernel')->updateModules($modules, $files); // New container, new module handler. $module_handler = \Drupal::moduleHandler(); diff --git a/core/tests/Drupal/KernelTests/Core/Common/DrupalFlushAllCachesTest.php b/core/tests/Drupal/KernelTests/Core/Common/DrupalFlushAllCachesTest.php new file mode 100644 index 000000000000..0953c05a4c7c --- /dev/null +++ b/core/tests/Drupal/KernelTests/Core/Common/DrupalFlushAllCachesTest.php @@ -0,0 +1,32 @@ +<?php + +namespace Drupal\KernelTests\Core\Common; + +use Drupal\KernelTests\KernelTestBase; + +/** + * @covers ::drupal_flush_all_caches + * @group Common + */ +class DrupalFlushAllCachesTest extends KernelTestBase { + + /** + * {@inheritdoc} + */ + protected static $modules = ['system']; + + /** + * Tests that drupal_flush_all_caches() uses core.extension properly. + */ + public function testDrupalFlushAllCachesModuleList() { + $core_extension = \Drupal::configFactory()->getEditable('core.extension'); + $module = $core_extension->get('module'); + $module['system_test'] = -10; + $core_extension->set('module', module_config_sort($module))->save(); + + drupal_flush_all_caches(); + + $this->assertSame(['system_test', 'system'], array_keys($this->container->getParameter('container.modules'))); + } + +} -- GitLab