Skip to content

Commit

Permalink
Issue #3119373 by alexpott, BramDriesen: Configuration synchronisatio…
Browse files Browse the repository at this point in the history
…n that both enables & configures a module fails and drupal_flush_all_caches()
  • Loading branch information
catch committed Mar 19, 2020
1 parent c898630 commit 6997fb3
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
5 changes: 4 additions & 1 deletion includes/common.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1062,12 +1062,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();

Expand Down
32 changes: 32 additions & 0 deletions tests/Drupal/KernelTests/Core/Common/DrupalFlushAllCachesTest.php
Original file line number Diff line number Diff line change
@@ -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', 'path_alias', 'system'], array_keys($this->container->getParameter('container.modules')));
}

}

0 comments on commit 6997fb3

Please sign in to comment.