By mr.baileys on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.x
Description:
The drupal_load() function has been removed. The function was used to manually load .module or module-related include files when these were not loaded automatically, for example to load a disabled module's .module file during uninstallation. Since modules can no longer be disabled, only uninstalled, there no longer is a need for drupal_load().
Before
function forum_uninstall() {
// Load the dependent Taxonomy module, in case it has been disabled.
drupal_load('module', 'taxonomy');
After
If you do need to manually include a .module or .inc file, use ModuleHandler::load(), ModuleHandler::loadInclude() or module_load_include(). Note that the ModuleHandler methods only work for enabled modules. For a module that isn't enabled, you will have to use module_load_include().
// Manually load the taxonomy.module file.
// Works regardless of module status, just like drupal_load() did.
module_load_include('module', 'taxonomy', 'taxonomy');
// Manually load the taxonomy.module file. Only works for enabled modules,
// so it is not a direct replacement for drupal_load().
\Drupal::moduleHandler()->load('taxonomy');
// Manually load the node.admin.inc file, only works for include files belonging to enabled modules.
\Drupal::moduleHandler()->loadInclude('node', 'inc', 'node.admin');
// Manually load the book.admin.inc file, works regardless of module status.
module_load_include('inc', 'book', 'book.admin');
Impacts:
Module developers