Commit 4846745b authored by catch's avatar catch
Browse files

Issue #3262931 by voleger, andypost: Remove drupal_required_modules() and mentions

parent 42630422
Loading
Loading
Loading
Loading
+0 −32
Original line number Diff line number Diff line
@@ -5,8 +5,6 @@
 * API for loading and interacting with Drupal modules.
 */

use Drupal\Core\Extension\ExtensionDiscovery;

/**
 * Loads a module include file.
 *
@@ -59,36 +57,6 @@ function module_load_include($type, $module, $name = NULL) {
  return FALSE;
}

/**
 * Returns an array of modules required by core.
 *
 * @deprecated in drupal:9.4.0 and is removed from drupal:10.0.0. There's no
 *   replacement.
 *
 * @see https://www.drupal.org/node/3262811
 */
function drupal_required_modules() {
  @trigger_error(__FUNCTION__ . "() is deprecated in drupal:9.4.0 and is removed from drupal:10.0.0. There's no replacement. See https://www.drupal.org/node/3262811", E_USER_DEPRECATED);
  $listing = new ExtensionDiscovery(\Drupal::root());
  $files = $listing->scan('module');
  $required = [];

  // Unless called by the installer, an installation profile is required and
  // must always be loaded.
  if ($profile = \Drupal::installProfile()) {
    $required[] = $profile;
  }

  foreach ($files as $name => $file) {
    $info = \Drupal::service('info_parser')->parse($file->getPathname());
    if (!empty($info) && !empty($info['required']) && $info['required']) {
      $required[] = $name;
    }
  }

  return $required;
}

/**
 * Sets weight of a particular module.
 *
+0 −21
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@

namespace Drupal\KernelTests\Core\Extension;

use Drupal\Core\Extension\ExtensionDiscovery;
use Drupal\KernelTests\KernelTestBase;

/**
@@ -23,24 +22,4 @@ public function testModuleLoadInclude() {

  }

  /**
   * Test deprecation of drupal_required_modules() function.
   */
  public function testDrupalRequiredModules() {
    $this->expectDeprecation("drupal_required_modules() is deprecated in drupal:9.4.0 and is removed from drupal:10.0.0. There's no replacement. See https://www.drupal.org/node/3262811");
    /** @var \Drupal\Core\Extension\InfoParserInterface $parser */
    $parser = \Drupal::service('info_parser');
    $listing = new ExtensionDiscovery(\Drupal::root());
    $files = $listing->scan('module');
    // Empty as there's no install profile.
    $required = [];
    foreach ($files as $name => $file) {
      $info = $parser->parse($file->getPathname());
      if (!empty($info) && !empty($info['required']) && $info['required']) {
        $required[] = $name;
      }
    }
    $this->assertSame($required, drupal_required_modules());
  }

}