From f31eaab4e3ab58de0f564efb46de3695216a2d8a Mon Sep 17 00:00:00 2001
From: Bob Vincent <bobvin@pillars.net>
Date: Thu, 6 Oct 2011 12:39:44 -0400
Subject: [PATCH] Issue #697946 by scor, pillarsdotnet: Deprecate the use of
 module_load_include() and remove its usage from core.

---
 includes/form.inc                        |    6 +++-
 includes/module.inc                      |   33 ++++++++++++++++++++++-------
 modules/dashboard/dashboard.module       |    2 +-
 modules/field/field.module               |    2 +-
 modules/forum/forum.admin.inc            |    2 +-
 modules/image/image.module               |    2 +-
 modules/image/image.test                 |    2 +-
 modules/node/node.module                 |    4 +-
 modules/openid/openid.module             |   16 +++++++-------
 modules/openid/openid.test               |    2 +-
 modules/openid/tests/openid_test.install |    2 +-
 modules/openid/tests/openid_test.module  |    4 +-
 modules/simpletest/tests/module.test     |    2 +-
 modules/system/system.updater.inc        |    2 +-
 modules/update/update.fetch.inc          |    2 +-
 modules/update/update.install            |    2 +-
 modules/update/update.manager.inc        |    6 ++--
 modules/update/update.module             |    8 +++---
 modules/update/update.report.inc         |    2 +-
 modules/user/user.admin.inc              |    2 +-
 modules/user/user.api.php                |    4 +-
 modules/user/user.module                 |    4 +-
 22 files changed, 65 insertions(+), 46 deletions(-)

diff --git a/includes/form.inc b/includes/form.inc
index 8c3b14ab4b2329035b4e3a5114d62f69e20c1f3c..df928ba0b961aa0feef6d6cea744b8731343c7a6 100644
--- a/includes/form.inc
+++ b/includes/form.inc
@@ -498,7 +498,7 @@ function form_get_cache($form_build_id, &$form_state) {
         foreach ($form_state['build_info']['files'] as $file) {
           if (is_array($file)) {
             $file += array('type' => 'inc', 'name' => $file['module']);
-            module_load_include($file['type'], $file['module'], $file['name']);
+            include_once(drupal_get_path('module', $file['module']) . '/' . $file['name'] . '.' . $file['type']);
           }
           elseif (file_exists($file)) {
             require_once DRUPAL_ROOT . '/' . $file;
@@ -597,7 +597,9 @@ function form_load_include(&$form_state, $type, $module, $name = NULL) {
   }
   if (!isset($form_state['build_info']['files']["$module:$name.$type"])) {
     // Only add successfully included files to the form state.
-    if ($result = module_load_include($type, $module, $name)) {
+    $path = drupal_get_path('module', $module) . "/$name.$type";
+    if (file_exists($path)) {
+      include_once($path);
       $form_state['build_info']['files']["$module:$name.$type"] = array(
         'type' => $type,
         'module' => $module,
diff --git a/includes/module.inc b/includes/module.inc
index e20e164a173cd3c1cc1603776f7e986fccd3552c..8a7c0db75c3dc91bd23d539a6675e43bb82982f8 100644
--- a/includes/module.inc
+++ b/includes/module.inc
@@ -260,12 +260,19 @@ function module_load_install($module) {
   // Make sure the installation API is available
   include_once DRUPAL_ROOT . '/includes/install.inc';
 
-  return module_load_include('install', $module);
+  $path = drupal_get_path('module', $module) . "/$module.install";
+  if (file_exists($path)) {
+    include_once($path);
+    return TRUE;
+  }
+  return FALSE;
 }
 
 /**
  * Load a module include file.
  *
+ * This function is deprecated and may be removed in future versions.
+ *
  * Examples:
  * @code
  *   // Load node.admin.inc from the node module.
@@ -274,9 +281,9 @@ function module_load_install($module) {
  *   module_load_include('inc', 'node', 'content_types');
  * @endcode
  *
- * Do not use this function to load an install file, use module_load_install()
+ * Do not use this function to load an install file; use module_load_install()
  * instead. Do not use this function in a global context since it requires
- * Drupal to be fully bootstrapped, use require_once DRUPAL_ROOT . '/path/file'
+ * Drupal to be fully bootstrapped; use include_once DRUPAL_ROOT . '/path/file'
  * instead.
  *
  * @param $type
@@ -312,7 +319,7 @@ function module_load_include($type, $module, $name = NULL) {
 function module_load_all_includes($type, $name = NULL) {
   $modules = module_list();
   foreach ($modules as $module) {
-    module_load_include($type, $module, $name);
+    include_once(drupal_get_path('module', $module) . '/' . ($name ? $name : $module) . ".$type");
   }
 }
 
@@ -605,7 +612,7 @@ function module_hook($module, $hook) {
   // optional include file registered via hook_hook_info().
   $hook_info = module_hook_info();
   if (isset($hook_info[$hook]['group'])) {
-    module_load_include('inc', $module, $module . '.' . $hook_info[$hook]['group']);
+    include_once(drupal_get_path('module', $module) . '/' . $module . '.' . $hook_info[$hook]['group'] . '.inc');
     if (function_exists($function)) {
       return TRUE;
     }
@@ -651,14 +658,24 @@ function module_implements($hook, $sort = FALSE) {
     // implementations, that the cache is updated at the end of the request.
     $implementations['#write_cache'] = TRUE;
     $hook_info = module_hook_info();
+    $group = isset($hook_info[$hook]['group']) ? $hook_info[$hook]['group'] : FALSE;
     $implementations[$hook] = array();
     $list = module_list(FALSE, FALSE, $sort);
     foreach ($list as $module) {
-      $include_file = isset($hook_info[$hook]['group']) && module_load_include('inc', $module, $module . '.' . $hook_info[$hook]['group']);
+      $include_file = FALSE;
+      if ($group) {
+        $include_file = drupal_get_path('module', $module) . "/$module.$group.inc";
+        if (file_exists($include_file)) {
+          include_once($include_file);
+        }
+        else {
+          $include_file = FALSE;
+        }
+      }
       // Since module_hook() may needlessly try to load the include file again,
       // function_exists() is used directly here.
       if (function_exists($module . '_' . $hook)) {
-        $implementations[$hook][$module] = $include_file ? $hook_info[$hook]['group'] : FALSE;
+        $implementations[$hook][$module] = $include_file ? $hook_group : FALSE;
       }
     }
     // Allow modules to change the weight of specific implementations but avoid
@@ -672,7 +689,7 @@ function module_implements($hook, $sort = FALSE) {
       // If this hook implementation is stored in a lazy-loaded file, so include
       // that file first.
       if ($group) {
-        module_load_include('inc', $module, "$module.$group");
+        include_once(drupal_get_path('module', $module) . "/$module.$group.inc");
       }
       // It is possible that a module removed a hook implementation without the
       // implementations cache being rebuilt yet, so we check whether the
diff --git a/modules/dashboard/dashboard.module b/modules/dashboard/dashboard.module
index 1216cc00c117f7ff2d3372d4466de6ebb9729ee9..6b998e5c222beb553e97a43f6bcc994f56f34382 100644
--- a/modules/dashboard/dashboard.module
+++ b/modules/dashboard/dashboard.module
@@ -311,7 +311,7 @@ function dashboard_admin($launch_customize = FALSE) {
 function dashboard_admin_blocks() {
   global $theme_key;
   drupal_theme_initialize();
-  module_load_include('inc', 'block', 'block.admin');
+  include_once(drupal_get_path('module', 'block') . '/block.admin.inc');
 
   // Prepare the blocks for the current theme, and remove those that are
   // currently displayed in non-dashboard regions.
diff --git a/modules/field/field.module b/modules/field/field.module
index f04c39c0cab95cf1205c4deacb77f05af85e166d..721175d9564792d7485fb0afce277973f492e96a 100644
--- a/modules/field/field.module
+++ b/modules/field/field.module
@@ -372,7 +372,7 @@ function field_cron() {
  * Implements hook_modules_uninstalled().
  */
 function field_modules_uninstalled($modules) {
-  module_load_include('inc', 'field', 'field.crud');
+  include_once(drupal_get_path('module', 'field') . '/field.crud.inc');
   foreach ($modules as $module) {
     // TODO D7: field_module_delete is not yet implemented
     // field_module_delete($module);
diff --git a/modules/forum/forum.admin.inc b/modules/forum/forum.admin.inc
index 49c71d90a0bf6c572ffec2b2399f9c8cb592c311..97bad028c4eb35c9260aa9f4d5a38c926419ae70 100644
--- a/modules/forum/forum.admin.inc
+++ b/modules/forum/forum.admin.inc
@@ -235,7 +235,7 @@ function forum_admin_settings($form) {
  * Returns an overview list of existing forums and containers
  */
 function forum_overview($form, &$form_state) {
-  module_load_include('inc', 'taxonomy', 'taxonomy.admin');
+  include_once(drupal_get_path('module', 'taxonomy', 'taxonomy.admin.inc'));
 
   $vid = variable_get('forum_nav_vocabulary', '');
   $vocabulary = taxonomy_vocabulary_load($vid);
diff --git a/modules/image/image.module b/modules/image/image.module
index 9e1c57ead92d8d0b718ceec4ce714bbda1b7fdab..000063b1978b5728289f413507ee85874f29caa3 100644
--- a/modules/image/image.module
+++ b/modules/image/image.module
@@ -1113,7 +1113,7 @@ function image_effect_delete($effect) {
  *   TRUE on success. FALSE if unable to perform the image effect on the image.
  */
 function image_effect_apply($image, $effect) {
-  module_load_include('inc', 'image', 'image.effects');
+  include_once(drupal_get_path('module', 'image') . '/image.effects.inc');
   $function = $effect['effect callback'];
   if (function_exists($function)) {
     return $function($image, $effect['data']);
diff --git a/modules/image/image.test b/modules/image/image.test
index 8596d66804048e25b570c77f1964801863e5ad41..20c5ec561291c96dc9a1cdddba30172463c318e6 100644
--- a/modules/image/image.test
+++ b/modules/image/image.test
@@ -229,7 +229,7 @@ class ImageEffectsUnitTest extends ImageToolkitTestCase {
 
   function setUp() {
     parent::setUp('image_test');
-    module_load_include('inc', 'image', 'image.effects');
+    include_once(drupal_get_path('module', 'image', 'image.effects.inc'));
   }
 
   /**
diff --git a/modules/node/node.module b/modules/node/node.module
index 0c3cfb7a006279b66b78ff03b76ba42e03477077..940332248c05279abdde9b967f69d6fdf22628d6 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -1732,7 +1732,7 @@ function node_user_cancel($edit, $account, $method) {
   switch ($method) {
     case 'user_cancel_block_unpublish':
       // Unpublish nodes (current revisions).
-      module_load_include('inc', 'node', 'node.admin');
+      include_once(drupal_get_path('module', 'node') . '/node.admin.inc');
       $nodes = db_select('node', 'n')
         ->fields('n', array('nid'))
         ->condition('uid', $account->uid)
@@ -1743,7 +1743,7 @@ function node_user_cancel($edit, $account, $method) {
 
     case 'user_cancel_reassign':
       // Anonymize nodes (current revisions).
-      module_load_include('inc', 'node', 'node.admin');
+      include_once(drupal_get_path('module', 'node') . '/node.admin.inc');
       $nodes = db_select('node', 'n')
         ->fields('n', array('nid'))
         ->condition('uid', $account->uid)
diff --git a/modules/openid/openid.module b/modules/openid/openid.module
index 2bf891ab69ac116dfa555223c24893e9c5d8d4d0..1a66d4c99a6d1d88effab173264ff509cb3bee6f 100644
--- a/modules/openid/openid.module
+++ b/modules/openid/openid.module
@@ -181,7 +181,7 @@ function _openid_user_login_form_alter(&$form, &$form_state) {
  */
 function openid_form_user_register_form_alter(&$form, &$form_state) {
   if (isset($_SESSION['openid']['response'])) {
-    module_load_include('inc', 'openid');
+    include_once(drupal_get_path('module', 'openid') . '/openid.inc');
 
     $response = $_SESSION['openid']['response'];
 
@@ -254,7 +254,7 @@ function openid_login_validate($form, &$form_state) {
  * @param $return_to The endpoint to return to from the OpenID Provider
  */
 function openid_begin($claimed_id, $return_to = '', $form_values = array()) {
-  module_load_include('inc', 'openid');
+  include_once(drupal_get_path('module', 'openid') . '/openid.inc');
 
   $service = NULL;
   $claimed_id = openid_normalize($claimed_id);
@@ -321,7 +321,7 @@ function openid_begin($claimed_id, $return_to = '', $form_values = array()) {
  *   $response['status'] set to one of 'success', 'failed' or 'cancel'.
  */
 function openid_complete($response = array()) {
-  module_load_include('inc', 'openid');
+  include_once(drupal_get_path('module', 'openid') . '/openid.inc');
 
   if (count($response) == 0) {
     $response = _openid_response();
@@ -406,7 +406,7 @@ function openid_complete($response = array()) {
  *   found, FALSE is returned.
  */
 function openid_discovery($claimed_id) {
-  module_load_include('inc', 'openid');
+  include_once(drupal_get_path('module', 'openid') . '/openid.inc');
 
   $methods = module_invoke_all('openid_discovery_method_info');
   drupal_alter('openid_discovery_method_info', $methods);
@@ -583,7 +583,7 @@ function openid_openid_normalization_method_info() {
  * @return $assoc_handle The association handle.
  */
 function openid_association($op_endpoint) {
-  module_load_include('inc', 'openid');
+  include_once(drupal_get_path('module', 'openid') . '/openid.inc');
 
   // Remove Old Associations:
   db_delete('openid_association')
@@ -708,7 +708,7 @@ function openid_authentication($response) {
 }
 
 function openid_association_request($public) {
-  module_load_include('inc', 'openid');
+  include_once(drupal_get_path('module', 'openid') . '/openid.inc');
 
   $request = array(
     'openid.ns' => OPENID_NS_2_0,
@@ -728,7 +728,7 @@ function openid_association_request($public) {
 function openid_authentication_request($claimed_id, $identity, $return_to = '', $assoc_handle = '', $service) {
   global $base_url;
 
-  module_load_include('inc', 'openid');
+  include_once(drupal_get_path('module', 'openid') . '/openid.inc');
 
   $request =  array(
     'openid.mode' => 'checkid_setup',
@@ -790,7 +790,7 @@ function openid_authentication_request($claimed_id, $identity, $return_to = '',
  * @see http://openid.net/specs/openid-authentication-2_0.html#rfc.section.11.4
  */
 function openid_verify_assertion($service, $response) {
-  module_load_include('inc', 'openid');
+  include_once(drupal_get_path('module', 'openid') . '/openid.inc');
 
   // http://openid.net/specs/openid-authentication-2_0.html#rfc.section.11.3
   // Check the Nonce to protect against replay attacks.
diff --git a/modules/openid/openid.test b/modules/openid/openid.test
index d873c32433747aa377dc6cc10730bedc0842a8ab..c036ca76614a5cad91afdd6a3a54b5c5a58cf375 100644
--- a/modules/openid/openid.test
+++ b/modules/openid/openid.test
@@ -549,7 +549,7 @@ class OpenIDUnitTest extends DrupalWebTestCase {
 
   function setUp() {
     parent::setUp('openid');
-    module_load_include('inc', 'openid');
+    include_once(drupal_get_path('module', 'openid') . '/openid.inc');
   }
 
   /**
diff --git a/modules/openid/tests/openid_test.install b/modules/openid/tests/openid_test.install
index 3bd4978f1a2eeeb0da9331fdeebfb0dc94744abe..5a245f8ea60afd41e842e2b9069077c77dca2ff0 100644
--- a/modules/openid/tests/openid_test.install
+++ b/modules/openid/tests/openid_test.install
@@ -9,7 +9,7 @@
  * Implements hook_install().
  */
 function openid_test_install() {
-  module_load_include('inc', 'openid');
+  include_once(drupal_get_path('module', 'openid') . '/openid.inc');
   // Generate a MAC key (Message Authentication Code) used for signing messages.
   // The variable is base64-encoded, because variables cannot contain non-UTF-8
   // data.
diff --git a/modules/openid/tests/openid_test.module b/modules/openid/tests/openid_test.module
index 629dcd3356a59023591f2be7518f64e6ba69d65d..e1405bda57f0bc428df68ddd86859abb6d6c6310 100644
--- a/modules/openid/tests/openid_test.module
+++ b/modules/openid/tests/openid_test.module
@@ -258,7 +258,7 @@ function openid_test_redirected_method($method1, $method2) {
  * the endpoint using drupal_http_request()).
  */
 function _openid_test_endpoint_associate() {
-  module_load_include('inc', 'openid');
+  include_once(drupal_get_path('module', 'openid') . '/openid.inc');
 
   // Use default parameters for Diffie-Helmann key exchange.
   $mod = OPENID_DH_DEFAULT_MOD;
@@ -307,7 +307,7 @@ function _openid_test_endpoint_associate() {
  * identity.
  */
 function _openid_test_endpoint_authenticate() {
-  module_load_include('inc', 'openid');
+  include_once(drupal_get_path('module', 'openid') . '/openid.inc');
 
   $expected_identity = variable_get('openid_test_identity');
   if ($expected_identity && $_REQUEST['openid_identity'] != $expected_identity) {
diff --git a/modules/simpletest/tests/module.test b/modules/simpletest/tests/module.test
index c9601c9b9ab7a0f8b76a706a374c0870bc42db32..5c6eb1f2d07f749ff58f7fde776ac3c8d2e01184 100644
--- a/modules/simpletest/tests/module.test
+++ b/modules/simpletest/tests/module.test
@@ -103,7 +103,7 @@ class ModuleUnitTest extends DrupalWebTestCase {
     // For that activate the module_test which provides the file to load.
     module_enable(array('module_test'));
 
-    module_load_include('inc', 'module_test', 'module_test.file');
+    include_once(drupal_get_path('module', 'module_test', 'module_test.file.inc'));
     $modules = module_implements('test_hook');
     $static = drupal_static('module_implements');
     $this->assertTrue(in_array('module_test', $modules), 'Hook found.');
diff --git a/modules/system/system.updater.inc b/modules/system/system.updater.inc
index 0df1ad955c8ed6b511f49480ba89be090d9ac629..51aeb2df9cbf66383b98bb60cb8011d55710c462 100644
--- a/modules/system/system.updater.inc
+++ b/modules/system/system.updater.inc
@@ -58,7 +58,7 @@ class ModuleUpdater extends Updater implements DrupalUpdaterInterface {
     if (_update_get_project_type($project) != 'module') {
       return array();
     }
-    module_load_include('install', $project);
+    include_once(drupal_get_path('module', $project) . "/$project.install");
 
     if (!$updates = drupal_get_schema_versions($project)) {
       return array();
diff --git a/modules/update/update.fetch.inc b/modules/update/update.fetch.inc
index 7ac0dbefbc2bb1555f87736823653fa9ec79b97d..d170260643dceab37923d8b046727cc04f0ae276 100644
--- a/modules/update/update.fetch.inc
+++ b/modules/update/update.fetch.inc
@@ -187,7 +187,7 @@ function _update_process_fetch_task($project) {
  * Clear out all the cached available update data and initiate re-fetching.
  */
 function _update_refresh() {
-  module_load_include('inc', 'update', 'update.compare');
+  include_once(drupal_get_path('module', 'update') . '/update.compare.inc');
 
   // Since we're fetching new available update data, we want to clear
   // our cache of both the projects we care about, and the current update
diff --git a/modules/update/update.install b/modules/update/update.install
index f0d549922a0d66d7995d535f9c6e0b3ab40eadcf..5981d4b5964bf62ea4d9965282b5c2021bc7f04d 100644
--- a/modules/update/update.install
+++ b/modules/update/update.install
@@ -30,7 +30,7 @@ function update_requirements($phase) {
   $requirements = array();
   if ($phase == 'runtime') {
     if ($available = update_get_available(FALSE)) {
-      module_load_include('inc', 'update', 'update.compare');
+      include_once(drupal_get_path('module', 'update') . '/update.compare.inc');
       $data = update_calculate_project_data($available);
       // First, populate the requirements for core:
       $requirements['update_core'] = _update_requirement_check($data['drupal'], 'core');
diff --git a/modules/update/update.manager.inc b/modules/update/update.manager.inc
index 59858ebe810ea6411b15786111653737d08a8804..cd95872cb299c29c48203039e1ff48bfcc726790 100644
--- a/modules/update/update.manager.inc
+++ b/modules/update/update.manager.inc
@@ -85,7 +85,7 @@ function update_manager_update_form($form, $form_state = array(), $context) {
   // project in the form, regardless of if it's enabled or disabled.
   $form['project_downloads'] = array('#tree' => TRUE);
 
-  module_load_include('inc', 'update', 'update.compare');
+  include_once(drupal_get_path('module', 'update') . '/update.compare.inc');
   $project_data = update_calculate_project_data($available);
   foreach ($project_data as $name => $project) {
     // Filter out projects which are up to date already.
@@ -435,7 +435,7 @@ function update_manager_update_ready_form_submit($form, &$form_state) {
     // credentials. Instead, we instantiate a FileTransferLocal and invoke
     // update_authorize_run_update() directly.
     if (fileowner($project_real_location) == fileowner(conf_path())) {
-      module_load_include('inc', 'update', 'update.authorize');
+      include_once(drupal_get_path('module', 'update') . '/update.authorize.inc');
       $filetransfer = new FileTransferLocal(DRUPAL_ROOT);
       update_authorize_run_update($filetransfer, $updates);
     }
@@ -710,7 +710,7 @@ function update_manager_install_form_submit($form, &$form_state) {
   // credentials. Instead, we instantiate a FileTransferLocal and invoke
   // update_authorize_run_install() directly.
   if (fileowner($project_real_location) == fileowner(conf_path())) {
-    module_load_include('inc', 'update', 'update.authorize');
+    include_once(drupal_get_path('module', 'update') . '/update.authorize.inc');
     $filetransfer = new FileTransferLocal(DRUPAL_ROOT);
     call_user_func_array('update_authorize_run_install', array_merge(array($filetransfer), $arguments));
   }
diff --git a/modules/update/update.module b/modules/update/update.module
index a2d705a0eb02bc5eed090c5f254caa85b863b3a0..ac428459e9ccd58715b911a06ad85f54cf675e36 100644
--- a/modules/update/update.module
+++ b/modules/update/update.module
@@ -377,7 +377,7 @@ function _update_no_data() {
  * @see update_get_projects()
  */
 function update_get_available($refresh = FALSE) {
-  module_load_include('inc', 'update', 'update.compare');
+  include_once(drupal_get_path('module', 'update') . '/update.compare.inc');
   $needs_refresh = FALSE;
 
   // Grab whatever data we currently have cached in the DB.
@@ -433,7 +433,7 @@ function update_get_available($refresh = FALSE) {
  * @see _update_create_fetch_task()
  */
 function update_create_fetch_task($project) {
-  module_load_include('inc', 'update', 'update.fetch');
+  include_once(drupal_get_path('module', 'update') . '/update.fetch.inc');
   return _update_create_fetch_task($project);
 }
 
@@ -443,7 +443,7 @@ function update_create_fetch_task($project) {
  * @see _update_refresh()
  */
 function update_refresh() {
-  module_load_include('inc', 'update', 'update.fetch');
+  include_once(drupal_get_path('module', 'update') . '/update.fetch.inc');
   return _update_refresh();
 }
 
@@ -451,7 +451,7 @@ function update_refresh() {
  * Wrapper to load the include file and then attempt to fetch update data.
  */
 function update_fetch_data() {
-  module_load_include('inc', 'update', 'update.fetch');
+  include_once(drupal_get_path('module', 'update') . '/update.fetch.inc');
   return _update_fetch_data();
 }
 
diff --git a/modules/update/update.report.inc b/modules/update/update.report.inc
index 3f5933acb1feeb6caf0ed61d823aaf0269d7f852..cecb393d64e45c479296db512caf77e2618d9dd5 100644
--- a/modules/update/update.report.inc
+++ b/modules/update/update.report.inc
@@ -10,7 +10,7 @@
  */
 function update_status() {
   if ($available = update_get_available(TRUE)) {
-    module_load_include('inc', 'update', 'update.compare');
+    include_once(drupal_get_path('module', 'update') . '/update.compare.inc');
     $data = update_calculate_project_data($available);
     return theme('update_report', array('data' => $data));
   }
diff --git a/modules/user/user.admin.inc b/modules/user/user.admin.inc
index 4789e7e73131b627a85dcc1e3a30b1815f1cbaf8..382689f84a75f9be2ab2ea0377c9687d8f2ae894 100644
--- a/modules/user/user.admin.inc
+++ b/modules/user/user.admin.inc
@@ -318,7 +318,7 @@ function user_admin_settings() {
     '#default_value' => variable_get('user_email_verification', TRUE),
     '#description' => t('New users will be required to validate their e-mail address prior to logging into the site, and will be assigned a system-generated password. With this setting disabled, users will be logged in immediately upon registering, and may select their own passwords during registration.')
   );
-  module_load_include('inc', 'user', 'user.pages');
+  include_once(drupal_get_path('module', 'user') . '/user.pages.inc');
   $form['registration_cancellation']['user_cancel_method'] = array(
     '#type' => 'item',
     '#title' => t('When cancelling a user account'),
diff --git a/modules/user/user.api.php b/modules/user/user.api.php
index 0b4f38f054a395d2c172165de76656ae1fe4635f..d6d44fb4958181e9f6de3576c447e1747242cc80 100644
--- a/modules/user/user.api.php
+++ b/modules/user/user.api.php
@@ -79,7 +79,7 @@ function hook_user_cancel($edit, $account, $method) {
   switch ($method) {
     case 'user_cancel_block_unpublish':
       // Unpublish nodes (current revisions).
-      module_load_include('inc', 'node', 'node.admin');
+      include_once(drupal_get_path('module', 'node') . '/node.admin.inc');
       $nodes = db_select('node', 'n')
         ->fields('n', array('nid'))
         ->condition('uid', $account->uid)
@@ -90,7 +90,7 @@ function hook_user_cancel($edit, $account, $method) {
 
     case 'user_cancel_reassign':
       // Anonymize nodes (current revisions).
-      module_load_include('inc', 'node', 'node.admin');
+      include_once(drupal_get_path('module', 'node') . '/node.admin.inc');
       $nodes = db_select('node', 'n')
         ->fields('n', array('nid'))
         ->condition('uid', $account->uid)
diff --git a/modules/user/user.module b/modules/user/user.module
index 14e145932f768fa703254f915260c4b4cb6f01a8..e8d4f99d96e9dce4a6ceac179137f9fdfb4a61ac 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -1753,7 +1753,7 @@ function user_menu_site_status_alter(&$menu_site_status, $path) {
   if ($menu_site_status == MENU_SITE_OFFLINE) {
     // If the site is offline, log out unprivileged users.
     if (user_is_logged_in() && !user_access('access site in maintenance mode')) {
-      module_load_include('pages.inc', 'user', 'user');
+      include_once(drupal_get_path('module', 'user') . '/user.pages.linc');
       user_logout();
     }
 
@@ -3193,7 +3193,7 @@ function user_multiple_cancel_confirm($form, &$form_state) {
 
   $form['operation'] = array('#type' => 'hidden', '#value' => 'cancel');
 
-  module_load_include('inc', 'user', 'user.pages');
+  include_once(drupal_get_path('module', 'user') . '/user.pages.inc');
   $form['user_cancel_method'] = array(
     '#type' => 'item',
     '#title' => t('When cancelling these accounts'),
-- 
1.7.5.4

