diff --git a/core/includes/update.inc b/core/includes/update.inc index 1a9066052c3da439104f1a4cc7c811706d88ee31..cdcae638258abb1bec4b3c0bca919c9cb50ad234 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -633,6 +633,7 @@ function update_module_enable(array $modules) { // installed module is always 0. Using 8000 here would be inconsistent // since $module_update_8000() may involve a schema change, and we want // to install the schema as it was before any updates were added. + module_load_install($module); $function = $module . '_schema_0'; if (function_exists($function)) { $schema = $function(); diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/SystemUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/SystemUpgradePathTest.php index ea6d6aaaaecfe2f0b2cfd1967828845be98740e1..2384f58b3c3ae2b3cbb8076002588375a376e16a 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/SystemUpgradePathTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/SystemUpgradePathTest.php @@ -108,4 +108,16 @@ public function testVariableUpgrade() { } } } + + /** + * Check whether views got enabled. + */ + public function testFrontpageUpgrade() { + $this->assertTrue($this->performUpgrade(), 'The upgrade was completed successfully.'); + + // Reset the module enable list to get the current result. + module_list_reset(); + $this->assertTrue(module_exists('views'), 'Views is enabled after the upgrade.'); + } + } diff --git a/core/modules/system/system.install b/core/modules/system/system.install index b63ca4607b0b405bb36628eccdf4066aec76323d..c0e3fe61bf09d239d3a069d7830fdf433334be53 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -2194,6 +2194,25 @@ function system_update_8045() { } } +/** + * Enable Views if the node listing is set as the frontpage. + */ +function system_update_8046() { + $front_page = config('system.site')->get('page.front'); + if (!isset($front_page) || $front_page == 'node') { + update_module_enable(array('views')); + + // Register views to the container, so views can use it's services. + $module_list = drupal_container()->getParameter('container.modules'); + drupal_load('module', 'views'); + + drupal_container()->get('kernel')->updateModules(array_keys($module_list), array('views' => 'core/modules/views/views.module')); + + // This does not fire a hook just calls views. + config_install_default_config('module', 'views'); + } +} + /** * @} End of "defgroup updates-7.x-to-8.x". * The next series of updates should start at 9000. diff --git a/core/modules/views/views.install b/core/modules/views/views.install index d395d0838221868f938b8f69354085f7320cd008..8bda10e539845d3e961ba6d30424319d9e5eb37d 100644 --- a/core/modules/views/views.install +++ b/core/modules/views/views.install @@ -26,3 +26,17 @@ function views_schema() { return $schema; } + +/** + * Provide an initial schema. + * + * @see update_module_enable(). + */ +function views_schema_0() { + module_load_install('system'); + // Add the cache_views_info and cache_views_results tables. + $cache_schema = system_schema_cache_8007(); + $schema['cache_views_info'] = $cache_schema; + $schema['cache_views_results'] = $cache_schema; + return $schema; +}