From 7dbda186ad6e7c0421f6ed41dcf7dfbf3d7d4155 Mon Sep 17 00:00:00 2001
From: Max Petyurenko <drupalrv@gmail.com>
Date: Tue, 23 Jul 2013 09:15:05 +0300
Subject: [PATCH] Issue #2045923, by benjy: replace all module_invoke_all()

---
 core/includes/common.inc                                     |  8 ++++----
 core/includes/entity.inc                                     |  4 ++--
 core/includes/file.inc                                       |  2 +-
 core/includes/form.inc                                       |  2 +-
 core/includes/language.inc                                   |  4 ++--
 core/includes/menu.inc                                       |  2 +-
 core/includes/path.inc                                       |  2 +-
 core/includes/theme.inc                                      |  4 ++--
 core/includes/update.inc                                     | 12 ++++++------
 .../Drupal/Core/Config/Entity/ConfigStorageController.php    |  4 ++--
 core/lib/Drupal/Core/Entity/DatabaseStorageController.php    |  4 ++--
 core/lib/Drupal/Core/Entity/EntityAccessController.php       |  4 ++--
 core/lib/Drupal/Core/Entity/EntityRenderController.php       |  6 +++---
 core/lib/Drupal/Core/Path/Path.php                           |  4 ++--
 .../lib/Drupal/comment/Plugin/Core/Entity/Comment.php        |  2 +-
 .../editor/lib/Drupal/editor/Plugin/Core/Entity/Editor.php   |  2 +-
 core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php  |  2 +-
 core/modules/field/field.attach.inc                          |  8 +++++---
 core/modules/field/field.crud.inc                            |  4 ++--
 core/modules/file/file.module                                |  6 +++---
 .../lib/Drupal/filter/Plugin/Core/Entity/FilterFormat.php    |  2 +-
 core/modules/image/image.module                              |  2 +-
 core/modules/language/language.module                        |  8 ++++----
 core/modules/node/lib/Drupal/node/NodeFormController.php     |  2 +-
 core/modules/node/lib/Drupal/node/NodeStorageController.php  |  4 ++--
 core/modules/node/node.module                                | 10 +++++-----
 core/modules/overlay/overlay.module                          |  4 ++--
 core/modules/rdf/rdf.module                                  |  2 +-
 .../search/lib/Drupal/search/Tests/SearchExactTest.php       |  2 +-
 .../search/lib/Drupal/search/Tests/SearchNodeAccessTest.php  |  2 +-
 .../search/lib/Drupal/search/Tests/SearchRankingTest.php     |  8 ++++----
 core/modules/search/search.api.php                           |  6 +++---
 core/modules/search/search.module                            |  2 +-
 core/modules/shortcut/shortcut.module                        |  2 +-
 .../simpletest/lib/Drupal/simpletest/UnitTestBase.php        |  2 +-
 .../modules/simpletest/lib/Drupal/simpletest/WebTestBase.php |  2 +-
 core/modules/simpletest/simpletest.module                    |  6 +++---
 .../system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php   |  2 +-
 .../system/lib/Drupal/system/Tests/Module/ModuleApiTest.php  |  4 ++--
 .../system/lib/Drupal/system/Tests/System/AdminTest.php      |  2 +-
 core/modules/system/system.module                            |  4 ++--
 .../system/tests/modules/module_test/module_test.module      |  4 ++--
 core/modules/toolbar/toolbar.module                          |  2 +-
 core/modules/update/update.manager.inc                       |  2 +-
 .../user/lib/Drupal/user/Plugin/views/access/Permission.php  |  2 +-
 core/modules/user/user.module                                |  4 ++--
 core/modules/xmlrpc/xmlrpc.server.inc                        |  2 +-
 core/profiles/standard/standard.install                      |  2 +-
 core/update.php                                              |  2 +-
 49 files changed, 93 insertions(+), 91 deletions(-)

diff --git a/core/includes/common.inc b/core/includes/common.inc
index a4805c0..ee45b2e 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -3229,7 +3229,7 @@ function drupal_cron_run() {

   $return = FALSE;
   // Grab the defined cron queues.
-  $queues = module_invoke_all('queue_info');
+  $queues = Drupal::moduleHandler()->invokeAll('queue_info');
   drupal_alter('queue_info', $queues);

   // Try to acquire cron lock.
@@ -4275,7 +4275,7 @@ function element_info($type) {
   $cache = &$drupal_static_fast['cache'];

   if (!isset($cache)) {
-    $cache = module_invoke_all('element_info');
+    $cache = Drupal::moduleHandler()->invokeAll('element_info');
     foreach ($cache as $element_type => $info) {
       $cache[$element_type]['#type'] = $element_type;
     }
@@ -4828,7 +4828,7 @@ function archiver_get_archiver($file) {
 function drupal_get_updaters() {
   $updaters = &drupal_static(__FUNCTION__);
   if (!isset($updaters)) {
-    $updaters = module_invoke_all('updater_info');
+    $updaters = Drupal::moduleHandler()->invokeAll('updater_info');
     drupal_alter('updater_info', $updaters);
     uasort($updaters, 'drupal_sort_weight');
   }
@@ -4848,7 +4848,7 @@ function drupal_get_updaters() {
 function drupal_get_filetransfer_info() {
   $info = &drupal_static(__FUNCTION__);
   if (!isset($info)) {
-    $info = module_invoke_all('filetransfer_info');
+    $info = Drupal::moduleHandler()->invokeAll('filetransfer_info');
     drupal_alter('filetransfer_info', $info);
     uasort($info, 'drupal_sort_weight');
   }
diff --git a/core/includes/entity.inc b/core/includes/entity.inc
index 2b3885e..e4c4092 100644
--- a/core/includes/entity.inc
+++ b/core/includes/entity.inc
@@ -65,7 +65,7 @@ function entity_get_bundles($entity_type = NULL) {
       $bundles = $cache->data;
     }
     else {
-      $bundles = module_invoke_all('entity_bundle_info');
+      $bundles = Drupal::moduleHandler()->invokeAll('entity_bundle_info');
       // If no bundles are provided, use the entity type name and label.
       foreach (entity_get_info() as $type => $entity_info) {
         if (!isset($bundles[$type])) {
@@ -102,7 +102,7 @@ function entity_get_bundles($entity_type = NULL) {
  */
 function entity_invoke_bundle_hook($hook, $entity_type, $bundle, $bundle_new = NULL) {
   entity_info_cache_clear();
-  module_invoke_all('entity_bundle_' . $hook, $entity_type, $bundle, $bundle_new);
+  Drupal::moduleHandler()->invokeAll('entity_bundle_' . $hook, array($entity_type, $bundle, $bundle_new));
 }

 /**
diff --git a/core/includes/file.inc b/core/includes/file.inc
index e70fa98..cb1ad01 100644
--- a/core/includes/file.inc
+++ b/core/includes/file.inc
@@ -189,7 +189,7 @@ function file_get_stream_wrappers($filter = STREAM_WRAPPERS_ALL) {
   $wrappers_storage = &drupal_static(__FUNCTION__);

   if (!isset($wrappers_storage)) {
-    $wrappers = module_invoke_all('stream_wrappers');
+    $wrappers = Drupal::moduleHandler()->invokeAll('stream_wrappers');
     foreach ($wrappers as $scheme => $info) {
       // Add defaults.
       $wrappers[$scheme] += array('type' => STREAM_WRAPPERS_NORMAL);
diff --git a/core/includes/form.inc b/core/includes/form.inc
index 5abf669..64e38a7 100644
--- a/core/includes/form.inc
+++ b/core/includes/form.inc
@@ -819,7 +819,7 @@ function drupal_retrieve_form($form_id, &$form_state) {
     // So, we call the hook if $forms isn't yet populated, OR if it doesn't
     // yet have an entry for the requested form_id.
     if (!isset($forms) || !isset($forms[$form_id])) {
-      $forms = module_invoke_all('forms', $form_id, $args);
+      $forms = Drupal::moduleHandler()->invokeAll('forms', array($form_id, $args));
     }
     $form_definition = $forms[$form_id];
     if (isset($form_definition['callback arguments'])) {
diff --git a/core/includes/language.inc b/core/includes/language.inc
index e63acaa..a3ee24d 100644
--- a/core/includes/language.inc
+++ b/core/includes/language.inc
@@ -161,7 +161,7 @@ function language_types_info() {
   $language_types = &drupal_static(__FUNCTION__);

   if (!isset($language_types)) {
-    $language_types = module_invoke_all('language_types_info');
+    $language_types = Drupal::moduleHandler()->invokeAll('language_types_info');
     // Let other modules alter the list of language types.
     drupal_alter('language_types_info', $language_types);
   }
@@ -413,7 +413,7 @@ function language_negotiation_info() {

   if (!isset($negotiation_info)) {
     // Collect all the module-defined language negotiation methods.
-    $negotiation_info = module_invoke_all('language_negotiation_info');
+    $negotiation_info = Drupal::moduleHandler()->invokeAll('language_negotiation_info');
     $languages = language_list();
     $selected_language = $languages[language_from_selected($languages)];
     $description = 'Language based on a selected language. ';
diff --git a/core/includes/menu.inc b/core/includes/menu.inc
index 08c7aff..b0a51a1 100644
--- a/core/includes/menu.inc
+++ b/core/includes/menu.inc
@@ -1776,7 +1776,7 @@ function menu_get_custom_theme($initialize = FALSE) {
     // First allow modules to dynamically set a custom theme for the current
     // page. Since we can only have one, the last module to return a valid
     // theme takes precedence.
-    $custom_themes = array_filter(module_invoke_all('custom_theme'), 'drupal_theme_access');
+    $custom_themes = array_filter(Drupal::moduleHandler()->invokeAll('custom_theme'), 'drupal_theme_access');
     if (!empty($custom_themes)) {
       $custom_theme = array_pop($custom_themes);
     }
diff --git a/core/includes/path.inc b/core/includes/path.inc
index 911cfe0..c4503c1 100644
--- a/core/includes/path.inc
+++ b/core/includes/path.inc
@@ -158,7 +158,7 @@ function path_is_admin($path) {
 function path_get_admin_paths() {
   $patterns = &drupal_static(__FUNCTION__);
   if (!isset($patterns)) {
-    $paths = module_invoke_all('admin_paths');
+    $paths = Drupal::moduleHandler()->invokeAll('admin_paths');
     drupal_alter('admin_paths', $paths);
     // Combine all admin paths into one array, and likewise for non-admin paths,
     // for easier handling.
diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index 7bff76e..6e5e02d 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -1527,7 +1527,7 @@ function theme_enable($theme_list) {
   drupal_theme_rebuild();

   // Invoke hook_themes_enabled() after the themes have been enabled.
-  module_invoke_all('themes_enabled', $theme_list);
+  Drupal::moduleHandler()->invokeAll('themes_enabled', array($theme_list));
 }

 /**
@@ -1563,7 +1563,7 @@ function theme_disable($theme_list) {
   drupal_theme_rebuild();

   // Invoke hook_themes_disabled after the themes have been disabled.
-  module_invoke_all('themes_disabled', $theme_list);
+  Drupal::moduleHandler()->invokeAll('themes_disabled', array($theme_list));
 }

 /**
diff --git a/core/includes/update.inc b/core/includes/update.inc
index 3ee24ab..272e822 100644
--- a/core/includes/update.inc
+++ b/core/includes/update.inc
@@ -1247,22 +1247,22 @@ function update_already_performed($module, $number) {
 /**
  * Invokes hook_update_dependencies() in all installed modules.
  *
- * This function is similar to module_invoke_all(), with the main difference
- * that it does not require that a module be enabled to invoke its hook, only
- * that it be installed. This allows the update system to properly perform
- * updates even on modules that are currently disabled.
+ * This function is similar to Drupal::moduleHandler()->invokeAll(), with the
+ * main difference that it does not require that a module be enabled to invoke
+ * its hook, only that it be installed. This allows the update system to
+ * properly perform updates even on modules that are currently disabled.
  *
  * @return
  *   An array of return values obtained by merging the results of the
  *   hook_update_dependencies() implementations in all installed modules.
  *
- * @see module_invoke_all()
+ * @see Drupal::moduleHandler()->invokeAll()
  * @see hook_update_dependencies()
  */
 function update_retrieve_dependencies() {
   $return = array();
   // Get a list of installed modules, arranged so that we invoke their hooks in
-  // the same order that module_invoke_all() does.
+  // the same order that Drupal::moduleHandler()->invokeAll() does.
   foreach (Drupal::keyValue('system.schema')->getAll() as $module => $schema) {
     if ($schema == SCHEMA_UNINSTALLED) {
       // Nothing to upgrade.
diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php
index 7fe3c49..7b05a38 100644
--- a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php
+++ b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php
@@ -450,9 +450,9 @@ public function baseFieldDefinitions() {
    */
   protected function invokeHook($hook, EntityInterface $entity) {
     // Invoke the hook.
-    module_invoke_all($this->entityType . '_' . $hook, $entity);
+    \Drupal::moduleHandler()->invokeAll($this->entityType . '_' . $hook, array($entity));
     // Invoke the respective entity-level hook.
-    module_invoke_all('entity_' . $hook, $entity, $this->entityType);
+    \Drupal::moduleHandler()->invokeAll('entity_' . $hook, array($entity, $this->entityType));
   }

   /**
diff --git a/core/lib/Drupal/Core/Entity/DatabaseStorageController.php b/core/lib/Drupal/Core/Entity/DatabaseStorageController.php
index e2dc1b4..9592ee2 100644
--- a/core/lib/Drupal/Core/Entity/DatabaseStorageController.php
+++ b/core/lib/Drupal/Core/Entity/DatabaseStorageController.php
@@ -547,9 +547,9 @@ protected function invokeHook($hook, EntityInterface $entity) {
       $function($entity);
     }
     // Invoke the hook.
-    module_invoke_all($this->entityType . '_' . $hook, $entity);
+    \Drupal::moduleHandler()->invokeAll($this->entityType . '_' . $hook, array($entity));
     // Invoke the respective entity-level hook.
-    module_invoke_all('entity_' . $hook, $entity, $this->entityType);
+    \Drupal::moduleHandler()->invokeAll('entity_' . $hook, array($entity, $this->entityType));
   }

   /**
diff --git a/core/lib/Drupal/Core/Entity/EntityAccessController.php b/core/lib/Drupal/Core/Entity/EntityAccessController.php
index 164b83e..425d089 100644
--- a/core/lib/Drupal/Core/Entity/EntityAccessController.php
+++ b/core/lib/Drupal/Core/Entity/EntityAccessController.php
@@ -58,7 +58,7 @@ public function access(EntityInterface $entity, $operation, $langcode = Language
     // We grant access to the entity if both of these conditions are met:
     // - No modules say to deny access.
     // - At least one module says to grant access.
-    $access = module_invoke_all($entity->entityType() . '_access', $entity->getBCEntity(), $operation, $account, $langcode);
+    $access = \Drupal::moduleHandler()->invokeAll($entity->entityType() . '_access', array($entity->getBCEntity(), $operation, $account, $langcode));

     if (($return = $this->processAccessHookResults($access)) === NULL) {
       // No module had an opinion about the access, so let's the access
@@ -196,7 +196,7 @@ public function createAccess($entity_bundle = NULL, AccountInterface $account =
     // We grant access to the entity if both of these conditions are met:
     // - No modules say to deny access.
     // - At least one module says to grant access.
-    $access = module_invoke_all($this->entity_type . '_create_access', $account, $context['langcode']);
+    $access = \Drupal::moduleHandler()->invokeAll($this->entity_type . '_create_access', array($account, $context['langcode']));

     if (($return = $this->processAccessHookResults($access)) === NULL) {
       // No module had an opinion about the access, so let's the access
diff --git a/core/lib/Drupal/Core/Entity/EntityRenderController.php b/core/lib/Drupal/Core/Entity/EntityRenderController.php
index cd92f52..69a579c 100644
--- a/core/lib/Drupal/Core/Entity/EntityRenderController.php
+++ b/core/lib/Drupal/Core/Entity/EntityRenderController.php
@@ -31,7 +31,7 @@ public function __construct($entity_type) {
    */
   public function buildContent(array $entities, array $displays, $view_mode, $langcode = NULL) {
     field_attach_prepare_view($this->entityType, $entities, $displays, $langcode);
-    module_invoke_all('entity_prepare_view', $this->entityType, $entities, $displays, $view_mode);
+    \Drupal::moduleHandler()->invokeAll('entity_prepare_view', array($this->entityType, $entities, $displays, $view_mode));

     foreach ($entities as $entity) {
       // Remove previously built content, if exists.
@@ -139,8 +139,8 @@ public function viewMultiple(array $entities = array(), $view_mode = 'full', $la
     foreach ($entities as $key => $entity) {
       $entity_view_mode = isset($entity->content['#view_mode']) ? $entity->content['#view_mode'] : $view_mode;
       $display = $displays[$entity_view_mode][$entity->bundle()];
-      module_invoke_all($view_hook, $entity, $display, $entity_view_mode, $langcode);
-      module_invoke_all('entity_view', $entity, $display, $entity_view_mode, $langcode);
+      \Drupal::moduleHandler()->invokeAll($view_hook, array($entity, $display, $entity_view_mode, $langcode));
+      \Drupal::moduleHandler()->invokeAll('entity_view', array($entity, $display, $entity_view_mode, $langcode));

       $build[$key] = $entity->content;
       // We don't need duplicate rendering info in $entity->content.
diff --git a/core/lib/Drupal/Core/Path/Path.php b/core/lib/Drupal/Core/Path/Path.php
index 4a3410f..ada1086 100644
--- a/core/lib/Drupal/Core/Path/Path.php
+++ b/core/lib/Drupal/Core/Path/Path.php
@@ -92,7 +92,7 @@ public function save($source, $alias, $langcode = Language::LANGCODE_NOT_SPECIFI
     }
     if ($pid) {
       // @todo Switch to using an event for this instead of a hook.
-      module_invoke_all($hook, $fields);
+      \Drupal::moduleHandler()->invokeAll($hook, array($fields));
       $this->alias_manager->cacheClear();
       return $fields;
     }
@@ -138,7 +138,7 @@ public function delete($conditions) {
     }
     $deleted = $query->execute();
     // @todo Switch to using an event for this instead of a hook.
-    module_invoke_all('path_delete', $path);
+    \Drupal::moduleHandler()->invokeAll('path_delete', array($path));
     $this->alias_manager->cacheClear();
     return $deleted;
   }
diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/Core/Entity/Comment.php b/core/modules/comment/lib/Drupal/comment/Plugin/Core/Entity/Comment.php
index 27dbf17..a7f8ce7 100644
--- a/core/modules/comment/lib/Drupal/comment/Plugin/Core/Entity/Comment.php
+++ b/core/modules/comment/lib/Drupal/comment/Plugin/Core/Entity/Comment.php
@@ -318,7 +318,7 @@ public function postSave(EntityStorageControllerInterface $storage_controller, $
     // Update the {node_comment_statistics} table prior to executing the hook.
     $storage_controller->updateNodeStatistics($this->nid->target_id);
     if ($this->status->value == COMMENT_PUBLISHED) {
-      module_invoke_all('comment_publish', $this);
+      \Drupal::moduleHandler()->invokeAll('comment_publish', array($this));
     }
   }

diff --git a/core/modules/editor/lib/Drupal/editor/Plugin/Core/Entity/Editor.php b/core/modules/editor/lib/Drupal/editor/Plugin/Core/Entity/Editor.php
index 710b991..9f568c7 100644
--- a/core/modules/editor/lib/Drupal/editor/Plugin/Core/Entity/Editor.php
+++ b/core/modules/editor/lib/Drupal/editor/Plugin/Core/Entity/Editor.php
@@ -79,7 +79,7 @@ public function __construct(array $values, $entity_type) {

     // Initialize settings, merging module-provided defaults.
     $default_settings = $plugin->getDefaultSettings();
-    $default_settings += module_invoke_all('editor_default_settings', $this->editor);
+    $default_settings += \Drupal::moduleHandler()->invokeAll('editor_default_settings', array($this->editor));
     drupal_alter('editor_default_settings', $default_settings, $this->editor);
     $this->settings += $default_settings;
   }
diff --git a/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php b/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php
index 99008e2..c069409 100644
--- a/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php
+++ b/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php
@@ -274,7 +274,7 @@ public function getHighestWeight() {
     }

     // Let other modules feedback about their own additions.
-    $weights = array_merge($weights, module_invoke_all('field_info_max_weight', $this->targetEntityType, $this->bundle, $this->displayContext, $this->mode));
+    $weights = array_merge($weights, \Drupal::moduleHandler()->invokeAll('field_info_max_weight', array($this->targetEntityType, $this->bundle, $this->displayContext, $this->mode)));

     return $weights ? max($weights) : NULL;
   }
diff --git a/core/modules/field/field.attach.inc b/core/modules/field/field.attach.inc
index 5ed17ff..37fc009 100644
--- a/core/modules/field/field.attach.inc
+++ b/core/modules/field/field.attach.inc
@@ -530,7 +530,8 @@ function field_attach_form(EntityInterface $entity, &$form, &$form_state, $langc
   $form['#bundle'] = $entity->bundle();

   // Let other modules make changes to the form.
-  // Avoid module_invoke_all() to let parameters be taken by reference.
+  // Avoid Drupal::moduleHandler()->invokeAll()
+  // to let parameters be taken by reference.
   foreach (module_implements('field_attach_form') as $module) {
     $function = $module . '_field_attach_form';
     $function($entity, $form, $form_state, $langcode);
@@ -700,7 +701,7 @@ function field_attach_load($entity_type, $entities, $age = FIELD_LOAD_CURRENT, $

     // Invoke hook_field_attach_load(): let other modules act on loading the
     // entity.
-    module_invoke_all('field_attach_load', $entity_type, $queried_entities, $age, $options);
+    Drupal::moduleHandler()->invokeAll('field_attach_load', array($entity_type, $queried_entities, $age, $options));

     // Build cache data.
     if ($cache_write) {
@@ -833,7 +834,8 @@ function field_attach_extract_form_values(EntityInterface $entity, $form, &$form
   field_invoke_method('extractFormValues', _field_invoke_widget_target($form_display), $entity, $form, $form_state, $options);

   // Let other modules act on submitting the entity.
-  // Avoid module_invoke_all() to let $form_state be taken by reference.
+  // Avoid Drupal::moduleHandler()->invokeAll()
+  // to let $form_state be taken by reference.
   foreach (module_implements('field_attach_extract_form_values') as $module) {
     $function = $module . 'field_attach_extract_form_values';
     $function($entity, $form, $form_state);
diff --git a/core/modules/field/field.crud.inc b/core/modules/field/field.crud.inc
index ed129df..7e3cb3a 100644
--- a/core/modules/field/field.crud.inc
+++ b/core/modules/field/field.crud.inc
@@ -352,7 +352,7 @@ function field_purge_instance($instance) {
   field_info_cache_clear();

   // Invoke external hooks after the cache is cleared for API consistency.
-  module_invoke_all('field_purge_instance', $instance);
+  Drupal::moduleHandler()->invokeAll('field_purge_instance', array($instance));
 }

 /**
@@ -382,7 +382,7 @@ function field_purge_field($field) {
   field_info_cache_clear();

   // Invoke external hooks after the cache is cleared for API consistency.
-  module_invoke_all('field_purge_field', $field);
+  Drupal::moduleHandler()->invokeAll('field_purge_field', array($field));
 }

 /**
diff --git a/core/modules/file/file.module b/core/modules/file/file.module
index 70dfdb4..e8a0234 100644
--- a/core/modules/file/file.module
+++ b/core/modules/file/file.module
@@ -206,7 +206,7 @@ function file_copy(File $source, $destination = NULL, $replace = FILE_EXISTS_REN
     $file->save();

     // Inform modules that the file has been copied.
-    module_invoke_all('file_copy', $file, $source);
+    Drupal::moduleHandler()->invokeAll('file_copy', array($file, $source));

     return $file;
   }
@@ -281,7 +281,7 @@ function file_move(File $source, $destination = NULL, $replace = FILE_EXISTS_REN
     $file->save();

     // Inform modules that the file has been moved.
-    module_invoke_all('file_move', $file, $source);
+    Drupal::moduleHandler()->invokeAll('file_move', array($file, $source));

     // Delete the original if it's not in use elsewhere.
     if ($delete_source && !file_usage()->listUsage($source)) {
@@ -325,7 +325,7 @@ function file_validate(File $file, $validators = array()) {
   }

   // Let other modules perform validation on the new file.
-  return array_merge($errors, module_invoke_all('file_validate', $file));
+  return array_merge($errors, Drupal::moduleHandler()->invokeAll('file_validate', array($file)));
 }

 /**
diff --git a/core/modules/filter/lib/Drupal/filter/Plugin/Core/Entity/FilterFormat.php b/core/modules/filter/lib/Drupal/filter/Plugin/Core/Entity/FilterFormat.php
index a853bb6..6d4705a 100644
--- a/core/modules/filter/lib/Drupal/filter/Plugin/Core/Entity/FilterFormat.php
+++ b/core/modules/filter/lib/Drupal/filter/Plugin/Core/Entity/FilterFormat.php
@@ -178,7 +178,7 @@ public function disable() {
     parent::disable();

     // Allow modules to react on text format deletion.
-    module_invoke_all('filter_format_disable', $this);
+    \Drupal::moduleHandler()->invokeAll('filter_format_disable', array($this));

     // Clear the filter cache whenever a text format is disabled.
     filter_formats_reset();
diff --git a/core/modules/image/image.module b/core/modules/image/image.module
index 62aee35..0e6f1c5 100644
--- a/core/modules/image/image.module
+++ b/core/modules/image/image.module
@@ -278,7 +278,7 @@ function image_file_download($uri) {
     // Check that the file exists and is an image.
     if ($info = image_get_info($uri)) {
       // Check the permissions of the original to grant access to this image.
-      $headers = module_invoke_all('file_download', $original_uri);
+      $headers = Drupal::moduleHandler()->invokeAll('file_download', array($original_uri));
       // Confirm there's at least one module granting access and none denying access.
       if (!empty($headers) && !in_array(-1, $headers)) {
         return array(
diff --git a/core/modules/language/language.module b/core/modules/language/language.module
index 7e5b87b..66433d3 100644
--- a/core/modules/language/language.module
+++ b/core/modules/language/language.module
@@ -497,7 +497,7 @@ function language_save($language) {
   $language->is_new = $language_entity->isNew();

   // Let other modules modify $language before saved.
-  module_invoke_all('language_presave', $language);
+  Drupal::moduleHandler()->invokeAll('language_presave', array($language));

   // Assign language properties to language entity.
   $language_entity->label = isset($language->name) ? $language->name : '';
@@ -509,11 +509,11 @@ function language_save($language) {
   $language_entity->save();
   $t_args = array('%language' => $language->name, '%langcode' => $language->id);
   if ($language->is_new) {
-    module_invoke_all('language_insert', $language);
+    Drupal::moduleHandler()->invokeAll('language_insert', array($language));
     watchdog('language', 'The %language (%langcode) language has been created.', $t_args);
   }
   else {
-    module_invoke_all('language_update', $language);
+    Drupal::moduleHandler()->invokeAll('language_update', array($language));
     watchdog('language', 'The %language (%langcode) language has been updated.', $t_args);
   }

@@ -571,7 +571,7 @@ function language_delete($langcode) {
   if (isset($languages[$langcode]) && !$languages[$langcode]->locked) {
     $language = $languages[$langcode];

-    module_invoke_all('language_delete', $language);
+    Drupal::moduleHandler()->invokeAll('language_delete', array($language));

     // Remove the language.
     entity_delete_multiple('language_entity', array($language->id));
diff --git a/core/modules/node/lib/Drupal/node/NodeFormController.php b/core/modules/node/lib/Drupal/node/NodeFormController.php
index db6480e..1cec21c 100644
--- a/core/modules/node/lib/Drupal/node/NodeFormController.php
+++ b/core/modules/node/lib/Drupal/node/NodeFormController.php
@@ -347,7 +347,7 @@ public function validate(array $form, array &$form_state) {
     }

     // Invoke hook_node_validate() for validation needed by modules.
-    // Can't use module_invoke_all(), because $form_state must
+    // Can't use Drupal::moduleHandler()->invokeAll(), because $form_state must
     // be receivable by reference.
     foreach (module_implements('node_validate') as $module) {
       $function = $module . '_node_validate';
diff --git a/core/modules/node/lib/Drupal/node/NodeStorageController.php b/core/modules/node/lib/Drupal/node/NodeStorageController.php
index c3ccc3c..01d53c0 100644
--- a/core/modules/node/lib/Drupal/node/NodeStorageController.php
+++ b/core/modules/node/lib/Drupal/node/NodeStorageController.php
@@ -91,9 +91,9 @@ protected function invokeHook($hook, EntityInterface $node) {
     }

     // Invoke the hook.
-    module_invoke_all($this->entityType . '_' . $hook, $node);
+    \Drupal::moduleHandler()->invokeAll($this->entityType . '_' . $hook, array($node));
     // Invoke the respective entity-level hook.
-    module_invoke_all('entity_' . $hook, $node, $this->entityType);
+    \Drupal::moduleHandler()->invokeAll('entity_' . $hook, array($node, $this->entityType));
   }

   /**
diff --git a/core/modules/node/node.module b/core/modules/node/node.module
index d0a928b..087ca8e 100644
--- a/core/modules/node/node.module
+++ b/core/modules/node/node.module
@@ -821,7 +821,7 @@ function node_permission() {
  *   A query object that has been extended with the Search DB Extender.
  */
 function _node_rankings(SelectExtender $query) {
-  if ($ranking = module_invoke_all('ranking')) {
+  if ($ranking = Drupal::moduleHandler()->invokeAll('ranking')) {
     $tables = &$query->getTables();
     foreach ($ranking as $rank => $values) {
       if ($node_rank = variable_get('node_rank_' . $rank, 0)) {
@@ -888,7 +888,7 @@ function node_search_admin() {

   // Note: reversed to reflect that higher number = higher ranking.
   $options = drupal_map_assoc(range(0, 10));
-  foreach (module_invoke_all('ranking') as $var => $values) {
+  foreach (Drupal::moduleHandler()->invokeAll('ranking') as $var => $values) {
     $form['content_ranking']['factors']['node_rank_' . $var] = array(
       '#title' => $values['title'],
       '#type' => 'select',
@@ -945,7 +945,7 @@ function node_search_execute($keys = NULL, $conditions = NULL) {
     // Fetch comments for snippet.
     $node->rendered .= ' ' . module_invoke('comment', 'node_update_index', $node, $item->langcode);

-    $extra = module_invoke_all('node_search_result', $node, $item->langcode);
+    $extra = Drupal::moduleHandler()->invokeAll('node_search_result', array($node, $item->langcode));

     $language = language_load($item->langcode);
     $uri = $node->uri();
@@ -1756,7 +1756,7 @@ function _node_index_node(EntityInterface $node) {
     $text = '<h1>' . check_plain($node->label($language->id)) . '</h1>' . $node->rendered;

     // Fetch extra data normally not visible.
-    $extra = module_invoke_all('node_update_index', $node, $language->id);
+    $extra = Drupal::moduleHandler()->invokeAll('node_update_index', array($node, $language->id));
     foreach ($extra as $t) {
       $text .= $t;
     }
@@ -2185,7 +2185,7 @@ function node_access_grants($op, $account = NULL) {
   }

   // Fetch node access grants from other modules.
-  $grants = module_invoke_all('node_grants', $account, $op);
+  $grants = Drupal::moduleHandler()->invokeAll('node_grants', array($account, $op));
   // Allow modules to alter the assigned grants.
   drupal_alter('node_grants', $grants, $account, $op);

diff --git a/core/modules/overlay/overlay.module b/core/modules/overlay/overlay.module
index 05c6fb8..4942c2a 100644
--- a/core/modules/overlay/overlay.module
+++ b/core/modules/overlay/overlay.module
@@ -479,14 +479,14 @@ function overlay_set_mode($mode = NULL) {
       drupal_add_library('overlay', 'drupal.overlay.parent');

       // Allow modules to act upon overlay events.
-      module_invoke_all('overlay_parent_initialize');
+      Drupal::moduleHandler()->invokeAll('overlay_parent_initialize');
       break;

     case 'child':
       drupal_add_library('overlay', 'drupal.overlay.child');

       // Allow modules to act upon overlay events.
-      module_invoke_all('overlay_child_initialize');
+      Drupal::moduleHandler()->invokeAll('overlay_child_initialize');
       break;
   }
   return $overlay_mode;
diff --git a/core/modules/rdf/rdf.module b/core/modules/rdf/rdf.module
index 23f47d6..171ce5d 100644
--- a/core/modules/rdf/rdf.module
+++ b/core/modules/rdf/rdf.module
@@ -109,7 +109,7 @@ function rdf_rdf_namespaces() {
 function rdf_get_namespaces() {
   $namespaces = array();
   // In order to resolve duplicate namespaces by using the earliest defined
-  // namespace, do not use module_invoke_all().
+  // namespace, do not use Drupal::moduleHandler()->invokeAll().
   foreach (module_implements('rdf_namespaces') as $module) {
     $function = $module . '_rdf_namespaces';
     if (function_exists($function)) {
diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchExactTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchExactTest.php
index c52549f..b593612 100644
--- a/core/modules/search/lib/Drupal/search/Tests/SearchExactTest.php
+++ b/core/modules/search/lib/Drupal/search/Tests/SearchExactTest.php
@@ -42,7 +42,7 @@ function testExactQuery() {
     }

     // Update the search index.
-    module_invoke_all('update_index');
+    \Drupal::moduleHandler()->invokeAll('update_index');
     search_update_totals();

     // Refresh variables after the treatment.
diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchNodeAccessTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchNodeAccessTest.php
index 67706cf..657eda2 100644
--- a/core/modules/search/lib/Drupal/search/Tests/SearchNodeAccessTest.php
+++ b/core/modules/search/lib/Drupal/search/Tests/SearchNodeAccessTest.php
@@ -45,7 +45,7 @@ function testPhraseSearchPunctuation() {
     $node = $this->drupalCreateNode(array('body' => array(array('value' => "The bunny's ears were fluffy."))));

     // Update the search index.
-    module_invoke_all('update_index');
+    \Drupal::moduleHandler()->invokeAll('update_index');
     search_update_totals();

     // Refresh variables after the treatment.
diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php
index 887e997..c7d84ae 100644
--- a/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php
+++ b/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php
@@ -63,7 +63,7 @@ function testRankings() {
     }

     // Update the search index.
-    module_invoke_all('update_index');
+    \Drupal::moduleHandler()->invokeAll('update_index');
     search_update_totals();

     // Refresh variables after the treatment.
@@ -143,7 +143,7 @@ function testHTMLRankings() {
     }

     // Update the search index.
-    module_invoke_all('update_index');
+    \Drupal::moduleHandler()->invokeAll('update_index');
     search_update_totals();

     // Refresh variables after the treatment.
@@ -173,7 +173,7 @@ function testHTMLRankings() {
       $node = $this->drupalCreateNode($settings);

       // Update the search index.
-      module_invoke_all('update_index');
+      \Drupal::moduleHandler()->invokeAll('update_index');
       search_update_totals();

       // Refresh variables after the treatment.
@@ -212,7 +212,7 @@ function testDoubleRankings() {
     $node = $this->drupalCreateNode($settings);

     // Update the search index.
-    module_invoke_all('update_index');
+    \Drupal::moduleHandler()->invokeAll('update_index');
     search_update_totals();

     // Refresh variables after the treatment.
diff --git a/core/modules/search/search.api.php b/core/modules/search/search.api.php
index 03b45aa..1a343d2 100644
--- a/core/modules/search/search.api.php
+++ b/core/modules/search/search.api.php
@@ -116,7 +116,7 @@ function hook_search_admin() {
   // Note: reversed to reflect that higher number = higher ranking.
   $options = drupal_map_assoc(range(0, 10));
   $ranks = config('node.settings')->get('search_rank');
-  foreach (module_invoke_all('ranking') as $var => $values) {
+  foreach (Drupal::moduleHandler()->invokeAll('ranking') as $var => $values) {
     $form['content_ranking']['factors'][$var] = array(
       '#title' => $values['title'],
       '#type' => 'select',
@@ -213,7 +213,7 @@ function hook_search_execute($keys = NULL, $conditions = NULL) {
     // Fetch comments for snippet.
     $node->rendered .= ' ' . module_invoke('comment', 'node_update_index', $node, $item->langcode);

-    $extra = module_invoke_all('node_search_result', $node, $item->langcode);
+    $extra = Drupal::moduleHandler()->invokeAll('node_search_result', array($node, $item->langcode));

     $language = language_load($item->langcode);
     $uri = $node->uri();
@@ -356,7 +356,7 @@ function hook_update_index() {
     $text = '<h1>' . check_plain($node->label()) . '</h1>' . $node->rendered;

     // Fetch extra data normally not visible
-    $extra = module_invoke_all('node_update_index', $node);
+    $extra = Drupal::moduleHandler()->invokeAll('node_update_index', array($node));
     foreach ($extra as $t) {
       $text .= $t;
     }
diff --git a/core/modules/search/search.module b/core/modules/search/search.module
index ba5434f..0e962a1 100644
--- a/core/modules/search/search.module
+++ b/core/modules/search/search.module
@@ -305,7 +305,7 @@ function _search_menu_access($name) {
  */
 function search_reindex($sid = NULL, $module = NULL, $reindex = FALSE, $langcode = NULL) {
   if ($module == NULL && $sid == NULL) {
-    module_invoke_all('search_reset');
+    Drupal::moduleHandler()->invokeAll('search_reset');
   }
   else {
     $query = db_delete('search_dataset')
diff --git a/core/modules/shortcut/shortcut.module b/core/modules/shortcut/shortcut.module
index c23577c..45bf45b 100644
--- a/core/modules/shortcut/shortcut.module
+++ b/core/modules/shortcut/shortcut.module
@@ -368,7 +368,7 @@ function shortcut_default_set($account = NULL) {
   // have one, we allow the last module which returns a valid result to take
   // precedence. If no module returns a valid set, fall back on the site-wide
   // default, which is the lowest-numbered shortcut set.
-  $suggestions = array_reverse(module_invoke_all('shortcut_default_set', $account));
+  $suggestions = array_reverse(Drupal::moduleHandler()->invokeAll('shortcut_default_set', array($account)));
   $suggestions[] = 'default';
   foreach ($suggestions as $name) {
     if ($shortcut_set = shortcut_set_load($name)) {
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/UnitTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/UnitTestBase.php
index b869360..71b02e4 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/UnitTestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/UnitTestBase.php
@@ -15,7 +15,7 @@
  *
  * These tests can not access the database nor files. Calling any Drupal
  * function that needs the database will throw exceptions. These include
- * watchdog(), module_implements(), module_invoke_all() etc.
+ * watchdog(), module_implements(), Drupal::moduleHandler()->invokeAll() etc.
  */
 abstract class UnitTestBase extends TestBase {

diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
index f0aa5fd..356b81f 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
@@ -579,7 +579,7 @@ protected function checkPermissions(array $permissions, $reset = FALSE) {
     $available = &drupal_static(__FUNCTION__);

     if (!isset($available) || $reset) {
-      $available = array_keys(module_invoke_all('permission'));
+      $available = array_keys(\Drupal::moduleHandler()->invokeAll('permission'));
     }

     $valid = TRUE;
diff --git a/core/modules/simpletest/simpletest.module b/core/modules/simpletest/simpletest.module
index 587b6c0..21aaa21 100644
--- a/core/modules/simpletest/simpletest.module
+++ b/core/modules/simpletest/simpletest.module
@@ -159,7 +159,7 @@ function simpletest_run_tests($test_list, $reporter = 'drupal') {
   );
   batch_set($batch);

-  module_invoke_all('test_group_started');
+  Drupal::moduleHandler()->invokeAll('test_group_started');

   return $test_id;
 }
@@ -305,7 +305,7 @@ function _simpletest_batch_operation($test_list_init, $test_id, &$context) {
   $size = count($test_list);
   $info = $test->getInfo();

-  module_invoke_all('test_finished', $test->results);
+  Drupal::moduleHandler()->invokeAll('test_finished', array($test->results));

   // Gather results and compose the report.
   $test_results[$test_class] = $test->results;
@@ -352,7 +352,7 @@ function _simpletest_batch_finished($success, $results, $operations, $elapsed) {
     drupal_set_message(t('The test run did not successfully finish.'), 'error');
     drupal_set_message(t('Use the <em>Clean environment</em> button to clean-up temporary files and tables.'), 'warning');
   }
-  module_invoke_all('test_group_finished');
+  Drupal::moduleHandler()->invokeAll('test_group_finished');
 }

 /**
diff --git a/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php b/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php
index c70cf9d..cc23e03 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php
@@ -37,7 +37,7 @@ public static function getInfo() {
   function setUp() {
     parent::setUp();

-    $perms = array_keys(module_invoke_all('permission'));
+    $perms = array_keys(\Drupal::moduleHandler()->invokeAll('permission'));
     $this->admin_user = $this->drupalCreateUser($perms);
     $this->drupalLogin($this->admin_user);

diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php
index a6322b0..eeaee6a 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php
@@ -127,13 +127,13 @@ function testModuleInvoke() {
   }

   /**
-   * Test that module_invoke_all() can load a hook defined in hook_hook_info().
+   * Test that Drupal::moduleHandler()->invokeAll() can load a hook defined in hook_hook_info().
    */
   function testModuleInvokeAll() {
     module_enable(array('module_test'), FALSE);
     $this->resetAll();
     $this->drupalGet('module-test/hook-dynamic-loading-invoke-all');
-    $this->assertText('success!', 'module_invoke_all() dynamically loads a hook defined in hook_hook_info().');
+    $this->assertText('success!', 'Drupal::moduleHandler()->invokeAll() dynamically loads a hook defined in hook_hook_info().');
   }

   /**
diff --git a/core/modules/system/lib/Drupal/system/Tests/System/AdminTest.php b/core/modules/system/lib/Drupal/system/Tests/System/AdminTest.php
index 1c42936..fb76a7a 100644
--- a/core/modules/system/lib/Drupal/system/Tests/System/AdminTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/System/AdminTest.php
@@ -36,7 +36,7 @@ function setUp() {
     // Create an administrator with all permissions, as well as a regular user
     // who can only access administration pages and perform some Locale module
     // administrative tasks, but not all of them.
-    $this->admin_user = $this->drupalCreateUser(array_keys(module_invoke_all('permission')));
+    $this->admin_user = $this->drupalCreateUser(array_keys(\Drupal::moduleHandler()->invokeAll('permission')));
     $this->web_user = $this->drupalCreateUser(array(
       'access administration pages',
       'translate interface',
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index 5d015ce..84092e9 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -2733,7 +2733,7 @@ function _system_rebuild_theme_data() {
   // Find themes
   $themes = drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.info.yml$/', 'themes');
   // Allow modules to add further themes.
-  if ($module_themes = module_invoke_all('system_theme_info')) {
+  if ($module_themes = Drupal::moduleHandler()->invokeAll('system_theme_info')) {
     foreach ($module_themes as $name => $uri) {
       // @see file_scan_directory()
       $themes[$name] = (object) array(
@@ -3184,7 +3184,7 @@ function system_cron() {
   // Cleanup the flood.
   Drupal::service('flood')->garbageCollection();

-  module_invoke_all('cache_flush');
+  Drupal::moduleHandler()->invokeAll('cache_flush');
   foreach (Cache::getBins() as $cache_backend) {
     $cache_backend->garbageCollection();
   }
diff --git a/core/modules/system/tests/modules/module_test/module_test.module b/core/modules/system/tests/modules/module_test/module_test.module
index 39caf92..fd1d2e6 100644
--- a/core/modules/system/tests/modules/module_test/module_test.module
+++ b/core/modules/system/tests/modules/module_test/module_test.module
@@ -110,7 +110,7 @@ function module_test_hook_dynamic_loading_invoke() {
  * return 'success!'.
  */
 function module_test_hook_dynamic_loading_invoke_all() {
-  $result = module_invoke_all('test_hook');
+  $result = Drupal::moduleHandler()->invokeAll('test_hook');
   return $result['module_test'];
 }

@@ -130,7 +130,7 @@ function module_test_hook_dynamic_loading_invoke_all_during_load($param) {
  * @see module_test_menu().
  */
 function module_test_load($param) {
-  $result = module_invoke_all('test_hook');
+  $result = Drupal::moduleHandler()->invokeAll('test_hook');
   return $result[$param];
 }

diff --git a/core/modules/toolbar/toolbar.module b/core/modules/toolbar/toolbar.module
index bae1b07..5dc1f15 100644
--- a/core/modules/toolbar/toolbar.module
+++ b/core/modules/toolbar/toolbar.module
@@ -201,7 +201,7 @@ function ($object) {
   }

   // Get toolbar items from all modules that implement hook_toolbar().
-  $items = module_invoke_all('toolbar');
+  $items = Drupal::moduleHandler()->invokeAll('toolbar');
   // Allow for altering of hook_toolbar().
   drupal_alter('toolbar', $items);
   // Sort the children.
diff --git a/core/modules/update/update.manager.inc b/core/modules/update/update.manager.inc
index 6b6767b..8628217 100644
--- a/core/modules/update/update.manager.inc
+++ b/core/modules/update/update.manager.inc
@@ -809,7 +809,7 @@ function update_manager_archive_extract($file, $directory) {
  *   are no errors, it will be an empty array.
  */
 function update_manager_archive_verify($project, $archive_file, $directory) {
-  return module_invoke_all('verify_update_archive', $project, $archive_file, $directory);
+  return Drupal::moduleHandler()->invokeAll('verify_update_archive', array($project, $archive_file, $directory));
 }

 /**
diff --git a/core/modules/user/lib/Drupal/user/Plugin/views/access/Permission.php b/core/modules/user/lib/Drupal/user/Plugin/views/access/Permission.php
index 0f4a387..6bee6fd 100644
--- a/core/modules/user/lib/Drupal/user/Plugin/views/access/Permission.php
+++ b/core/modules/user/lib/Drupal/user/Plugin/views/access/Permission.php
@@ -46,7 +46,7 @@ public function alterRouteDefinition(Route $route) {
   }

   public function summaryTitle() {
-    $permissions = module_invoke_all('permission');
+    $permissions = \Drupal::moduleHandler()->invokeAll('permission');
     if (isset($permissions[$this->options['perm']])) {
       return $permissions[$this->options['perm']]['title'];
     }
diff --git a/core/modules/user/user.module b/core/modules/user/user.module
index 924b221..5fc8728 100644
--- a/core/modules/user/user.module
+++ b/core/modules/user/user.module
@@ -1161,7 +1161,7 @@ function user_login_finalize(UserInterface $account) {
   // or incorrectly does a redirect which would leave the old session in place.
   drupal_session_regenerate();

-  module_invoke_all('user_login', $user);
+  Drupal::moduleHandler()->invokeAll('user_login', array($user));
 }

 /**
@@ -1298,7 +1298,7 @@ function user_cancel($edit, $uid, $method) {
   // should use those hooks to respond to the account deletion.
   if ($method != 'user_cancel_delete') {
     // Allow modules to add further sets to this batch.
-    module_invoke_all('user_cancel', $edit, $account, $method);
+    Drupal::moduleHandler()->invokeAll('user_cancel', array($edit, $account, $method));
   }

   // Finish the batch and actually cancel the account.
diff --git a/core/modules/xmlrpc/xmlrpc.server.inc b/core/modules/xmlrpc/xmlrpc.server.inc
index fded011..b68ccbb 100644
--- a/core/modules/xmlrpc/xmlrpc.server.inc
+++ b/core/modules/xmlrpc/xmlrpc.server.inc
@@ -16,7 +16,7 @@
  */
 function xmlrpc_server_page() {
   module_load_include('inc', 'xmlrpc');
-  return xmlrpc_server(module_invoke_all('xmlrpc'));
+  return xmlrpc_server(Drupal::moduleHandler()->invokeAll('xmlrpc'));
 }

 /**
diff --git a/core/profiles/standard/standard.install b/core/profiles/standard/standard.install
index 5c29f4d..f74841e 100644
--- a/core/profiles/standard/standard.install
+++ b/core/profiles/standard/standard.install
@@ -40,7 +40,7 @@ function standard_install() {
   user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('access content', 'access comments', 'post comments', 'skip comment approval'));

   // Enable all permissions for the administrator role.
-  user_role_grant_permissions('administrator', array_keys(module_invoke_all('permission')));
+  user_role_grant_permissions('administrator', array_keys(Drupal::moduleHandler()->invokeAll('permission')));
   // Set this as the administrator role.
   $user_settings->set('admin_role', 'administrator')->save();

diff --git a/core/update.php b/core/update.php
index 8608f97..387fe35 100644
--- a/core/update.php
+++ b/core/update.php
@@ -405,7 +405,7 @@ function update_extra_requirements($requirements = NULL) {
  */
 function update_check_requirements($skip_warnings = FALSE) {
   // Check requirements of all loaded modules.
-  $requirements = module_invoke_all('requirements', 'update');
+  $requirements = Drupal::moduleHandler()->invokeAll('requirements', array('update'));
   $requirements += update_extra_requirements();
   $severity = drupal_requirements_severity($requirements);

--
1.8.3.msysgit.0

