diff --git a/core/includes/update.inc b/core/includes/update.inc index 1a90660..cdcae63 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 ea6d6aa..2384f58 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 b63ca46..c0e3fe6 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -2195,6 +2195,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 d395d08..0fbdfd6 100644 --- a/core/modules/views/views.install +++ b/core/modules/views/views.install @@ -26,3 +26,19 @@ function views_schema() { return $schema; } + +/** + * Implements hook_schema_0(). + * + * @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; +}