diff --git a/core/includes/install.inc b/core/includes/install.inc index 2b3232942c332e5d2703b56fec09b9c86b420e97..00a4a3459ed12a764bc88ccc7542a9c66d7dfc7c 100644 --- a/core/includes/install.inc +++ b/core/includes/install.inc @@ -84,7 +84,7 @@ function drupal_load_updates() { foreach (\Drupal::service('update.update_hook_registry')->getAllInstalledVersions() as $module => $schema_version) { if ($extension_list_module->exists($module) && !$extension_list_module->checkIncompatibility($module)) { if ($schema_version > -1) { - module_load_install($module); + \Drupal::moduleHandler()->loadInclude($module, 'install'); } } } @@ -1033,7 +1033,12 @@ function drupal_requirements_severity(&$requirements) { * TRUE or FALSE, depending on whether the requirements are met. */ function drupal_check_module($module) { - module_load_install($module); + /** @var \Drupal\Core\Extension\ModuleExtensionList $module_list */ + $module_list = \Drupal::service('extension.list.module'); + $file = DRUPAL_ROOT . '/' . $module_list->getPath($module) . "/$module.install"; + if (is_file($file)) { + require_once $file; + } // Check requirements $requirements = \Drupal::moduleHandler()->invoke($module, 'requirements', ['install']); if (is_array($requirements) && drupal_requirements_severity($requirements) == REQUIREMENT_ERROR) { diff --git a/core/includes/module.inc b/core/includes/module.inc index d718a31492be3468fe5598713e21824576cb38dd..cee6f894694adfddca8feb8fc360266dcef22e3f 100644 --- a/core/includes/module.inc +++ b/core/includes/module.inc @@ -15,8 +15,15 @@ * * @return * The name of the module's install file, if successful; FALSE otherwise. + * + * @deprecated in drupal:9.4.0 and is removed from drupal:10.0.0. Use + * \Drupal::moduleHandler()->loadInclude($module, 'install') instead. Note, + * the replacement no longer allows including code from uninstalled modules. + * + * @see https://www.drupal.org/node/3220952 */ function module_load_install($module) { + @trigger_error('module_load_install() is deprecated in drupal:9.4.0 and is removed from drupal:10.0.0. Instead, you should use \Drupal::moduleHandler()->loadInclude($module, \'install\'). Note, the replacement no longer allows including code from uninstalled modules. See https://www.drupal.org/project/drupal/issues/2010380', E_USER_DEPRECATED); // Make sure the installation API is available include_once __DIR__ . '/install.inc'; diff --git a/core/includes/update.inc b/core/includes/update.inc index 7c37673f915780e250585254046626d83b2b10d6..2dbcd3ce3595b2c8580a213c5fbbef034e0e1383 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -115,7 +115,7 @@ function _update_fix_missing_schema() { // don't, detect and fix the problem. if (!isset($versions[$module])) { // Ensure the .install file is loaded. - module_load_install($module); + $module_handler->loadInclude($module, 'install'); $all_updates = $update_registry->getAvailableUpdates($module); // If the schema version of a module hasn't been recorded, we cannot // know the actual schema version a module is at, because @@ -704,7 +704,7 @@ function update_retrieve_dependencies() { } $function = $module . '_update_dependencies'; // Ensure install file is loaded. - module_load_install($module); + \Drupal::moduleHandler()->loadInclude($module, 'install'); if (function_exists($function)) { $updated_dependencies = $function(); // Each implementation of hook_update_dependencies() returns a diff --git a/core/lib/Drupal/Core/Extension/ModuleInstaller.php b/core/lib/Drupal/Core/Extension/ModuleInstaller.php index 8b24bcdf123c8ac058fa3cd9f7d8dd592fa75d53..4669bb7cc873cbc99823ab11a72fc3ddeca273be 100644 --- a/core/lib/Drupal/Core/Extension/ModuleInstaller.php +++ b/core/lib/Drupal/Core/Extension/ModuleInstaller.php @@ -242,7 +242,7 @@ public function install(array $module_list, $enable_dependencies = TRUE) { // Load the module's .module and .install files. $this->moduleHandler->load($module); - module_load_install($module); + $this->moduleHandler->loadInclude($module, 'install'); if (!InstallerKernel::installationAttempted()) { // Replace the route provider service with a version that will rebuild @@ -468,7 +468,7 @@ public function uninstall(array $module_list, $uninstall_dependents = TRUE) { $this->moduleHandler->invokeAll('module_preuninstall', [$module]); // Uninstall the module. - module_load_install($module); + $this->moduleHandler->loadInclude($module, 'install'); $this->moduleHandler->invoke($module, 'uninstall', [$sync_status]); // Remove all configuration belonging to the module. diff --git a/core/lib/Drupal/Core/Installer/Form/SelectProfileForm.php b/core/lib/Drupal/Core/Installer/Form/SelectProfileForm.php index 82b7d3c9e251ca8387093b02b991665641a4e7cd..98578d10f816a76f7c8f939f7bf8253c0db78083 100644 --- a/core/lib/Drupal/Core/Installer/Form/SelectProfileForm.php +++ b/core/lib/Drupal/Core/Installer/Form/SelectProfileForm.php @@ -93,7 +93,12 @@ public function buildForm(array $form, FormStateInterface $form_state, $install_ // profile's which implement hook_INSTALL() are not supported. // @todo https://www.drupal.org/project/drupal/issues/2982052 Remove // this restriction. - module_load_install($extensions['profile']); + $root = \Drupal::root(); + include_once $root . '/core/includes/install.inc'; + $file = $root . '/' . $install_state['profiles'][$extensions['profile']]->getPath() . "/{$extensions['profile']}.install"; + if (is_file($file)) { + require_once $file; + } if (!function_exists($extensions['profile'] . '_install')) { $form['profile']['#options'][static::CONFIG_INSTALL_PROFILE_KEY] = $this->t('Use existing configuration'); $form['profile'][static::CONFIG_INSTALL_PROFILE_KEY]['#description'] = [ diff --git a/core/modules/system/tests/src/Functional/System/SitesDirectoryHardeningTest.php b/core/modules/system/tests/src/Functional/System/SitesDirectoryHardeningTest.php index 9a4f57d7dcbbebe0ac72c68d10cb04ec9884f200..b4de6473882105cc7508e84ea829e6783cd17447 100644 --- a/core/modules/system/tests/src/Functional/System/SitesDirectoryHardeningTest.php +++ b/core/modules/system/tests/src/Functional/System/SitesDirectoryHardeningTest.php @@ -92,7 +92,7 @@ public function testSitesDirectoryHardeningConfig() { * An array of system requirements. */ protected function checkSystemRequirements() { - module_load_install('system'); + \Drupal::moduleHandler()->loadInclude('system', 'install'); return system_requirements('runtime'); } diff --git a/core/modules/update/update.fetch.inc b/core/modules/update/update.fetch.inc index b418d9c3ec3e69d884512537d81ff8dbef91a089..b1ab4196689a8947430474edeb1be4faf6cff1cb 100644 --- a/core/modules/update/update.fetch.inc +++ b/core/modules/update/update.fetch.inc @@ -18,7 +18,7 @@ */ function _update_cron_notify() { $update_config = \Drupal::config('update.settings'); - module_load_install('update'); + \Drupal::moduleHandler()->loadInclude('update', 'install'); $status = update_requirements('runtime'); $params = []; $notify_all = ($update_config->get('notification.threshold') == 'all'); diff --git a/core/modules/update/update.module b/core/modules/update/update.module index 7a1a927ab7c32bca38ec3daf68e560c0e0ee31e5..4eb82ebb672d0a78cd06f37b9cbbba07113d0cc9 100644 --- a/core/modules/update/update.module +++ b/core/modules/update/update.module @@ -92,7 +92,7 @@ function update_page_top() { break; } - module_load_install('update'); + \Drupal::moduleHandler()->loadInclude('update', 'install'); $status = update_requirements('runtime'); foreach (['core', 'contrib'] as $report_type) { $type = 'update_' . $report_type; diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php index e55211d347d01a02e6eeb800987db971a80b607d..7c701f1b269a3461d1eed1c4e1498b00fa97544e 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php @@ -64,7 +64,7 @@ protected function setUp(): void { } // Create the test field. - module_load_install('entity_test'); + $this->container->get('module_handler')->loadInclude('entity_test', 'install'); entity_test_install(); // Install required default configuration for filter module. diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityLanguageTestBase.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityLanguageTestBase.php index 52b364a19328e4975363eec4df9a12d4a73027f5..1182e47f60faa933d9a70fd11369b2f3e19fb3a6 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityLanguageTestBase.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityLanguageTestBase.php @@ -56,7 +56,7 @@ protected function setUp(): void { $this->installConfig(['language']); // Create the test field. - module_load_install('entity_test'); + $this->container->get('module_handler')->loadInclude('entity_test', 'install'); entity_test_install(); // Enable translations for the test entity type. diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityValidationTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityValidationTest.php index 09298d4673f41a9c66a2b46245da990325e88bc4..c4426c3c7c4ff7e0b1ee4f13fc857996ae2401bb 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityValidationTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityValidationTest.php @@ -52,7 +52,7 @@ protected function setUp(): void { $this->installEntitySchema('entity_test_mulrev_changed'); // Create the test field. - module_load_install('entity_test'); + $this->container->get('module_handler')->loadInclude('entity_test', 'install'); entity_test_install(); // Install required default configuration for filter module. diff --git a/core/tests/Drupal/KernelTests/Core/Extension/ModuleLegacyTest.php b/core/tests/Drupal/KernelTests/Core/Extension/ModuleLegacyTest.php index 1b281c286a7297fc74e32e0fe036837021122a96..848170099e6b80f3ec0d60ae5baf25e494571c55 100644 --- a/core/tests/Drupal/KernelTests/Core/Extension/ModuleLegacyTest.php +++ b/core/tests/Drupal/KernelTests/Core/Extension/ModuleLegacyTest.php @@ -22,4 +22,14 @@ public function testModuleLoadInclude() { } + /** + * Test deprecation of module_load_install() function. + */ + public function testModuleLoadInstall() { + $this->assertFalse(\Drupal::moduleHandler()->moduleExists('node'), 'The Node module is not installed'); + $this->expectDeprecation('module_load_install() is deprecated in drupal:9.4.0 and is removed from drupal:10.0.0. Instead, you should use \Drupal::moduleHandler()->loadInclude($module, \'install\'). Note, the replacement no longer allows including code from uninstalled modules. See https://www.drupal.org/project/drupal/issues/2010380'); + $filename = module_load_install('node'); + $this->assertStringEndsWith("node.install", $filename); + } + } diff --git a/core/tests/Drupal/KernelTests/Core/Field/FieldAccessTest.php b/core/tests/Drupal/KernelTests/Core/Field/FieldAccessTest.php index c8f306039f0dfe711a12bd2c0b6ec020dbaf8597..02b155534e680eaed50f85764bc7f8ee6d7794bb 100644 --- a/core/tests/Drupal/KernelTests/Core/Field/FieldAccessTest.php +++ b/core/tests/Drupal/KernelTests/Core/Field/FieldAccessTest.php @@ -54,7 +54,7 @@ protected function setUp(): void { // The users table is needed for creating dummy user accounts. $this->installEntitySchema('user'); // Register entity_test text field. - module_load_install('entity_test'); + $this->container->get('module_handler')->loadInclude('entity_test', 'install'); entity_test_install(); } diff --git a/core/tests/Drupal/KernelTests/Core/File/FileSystemRequirementsTest.php b/core/tests/Drupal/KernelTests/Core/File/FileSystemRequirementsTest.php index 42554285324330d2d7412fdf79ceb723db6fcf3d..ac8b802df3659df05443119f0b837f3f85dcbd1c 100644 --- a/core/tests/Drupal/KernelTests/Core/File/FileSystemRequirementsTest.php +++ b/core/tests/Drupal/KernelTests/Core/File/FileSystemRequirementsTest.php @@ -45,7 +45,7 @@ public function testSettingsExist() { * An array of system requirements. */ protected function checkSystemRequirements() { - module_load_install('system'); + $this->container->get('module_handler')->loadInclude('system', 'install'); return system_requirements('runtime'); }