Commit 9defd332 authored by catch's avatar catch
Browse files

Issue #2010380 by alexpott, TR, tstoeckler, MerryHamster, sanjayk, andypost,...

Issue #2010380 by alexpott, TR, tstoeckler, MerryHamster, sanjayk, andypost, chx, Pancho, daffie: Deprecate module_load_install() and replace it with ModuleHandler::loadInstall
parent c5bd67a8
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -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) {
+7 −0
Original line number Diff line number Diff line
@@ -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';

+2 −2
Original line number Diff line number Diff line
@@ -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
+2 −2
Original line number Diff line number Diff line
@@ -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.
+6 −1
Original line number Diff line number Diff line
@@ -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'] = [
Loading