Unverified Commit 9e6fedbd authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3260781 by andypost: Remove deprecated module.inc functions

parent 5f332d85
Loading
Loading
Loading
Loading
+0 −32
Original line number Diff line number Diff line
@@ -7,38 +7,6 @@

use Drupal\Core\Extension\ExtensionDiscovery;

/**
 * Loads a module's installation hooks.
 *
 * @param $module
 *   The name of the module (without the .module extension).
 *
 * @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';

  if (\Drupal::hasService('extension.list.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;
      return $file;
    }
  }
  return FALSE;
}

/**
 * Loads a module include file.
 *
+1 −1
Original line number Diff line number Diff line
@@ -632,7 +632,7 @@ function update_retrieve_dependencies() {
  // the same order that \Drupal::moduleHandler()->invokeAll() does.
  foreach ($update_registry->getAllInstalledVersions() as $module => $schema) {
    // Skip modules that are entirely missing from the filesystem here, since
    // module_load_install() will call trigger_error() if invoked on a module
    // loading .install file will call trigger_error() if invoked on a module
    // that doesn't exist. There's no way to catch() that, so avoid it entirely.
    // This can happen when there are orphaned entries in the system.schema k/v
    // store for modules that have been removed from a site without first being
+0 −10
Original line number Diff line number Diff line
@@ -22,14 +22,4 @@ 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);
  }

}