diff --git a/core/includes/install.inc b/core/includes/install.inc
index 1038818..dbbb82e 100644
--- a/core/includes/install.inc
+++ b/core/includes/install.inc
@@ -107,6 +107,7 @@ function drupal_install_profile_distribution_name() {
   // At all other times, we load the profile via standard methods.
   else {
     $profile = drupal_get_profile();
+    \Drupal::moduleHandler()->load('system');
     $info = system_get_info('module', $profile);
   }
   return isset($info['distribution']['name']) ? $info['distribution']['name'] : 'Drupal';
diff --git a/core/includes/update.inc b/core/includes/update.inc
index 510dc8c..8d14e96 100644
--- a/core/includes/update.inc
+++ b/core/includes/update.inc
@@ -44,6 +44,7 @@ function update_check_incompatibility($name, $type = 'module') {
     // We need to do a full rebuild here to make sure the database reflects any
     // code changes that were made in the filesystem before the update script
     // was initiated.
+    \Drupal::moduleHandler()->load('system');
     $themes = system_rebuild_theme_data();
     $modules = system_rebuild_module_data();
   }
diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php
index 2c58ccc..45fbcea 100644
--- a/core/lib/Drupal/Core/DrupalKernel.php
+++ b/core/lib/Drupal/Core/DrupalKernel.php
@@ -437,7 +437,7 @@ public function getContainer() {
    */
   public function preHandle(Request $request) {
     // Load all enabled modules.
-    $this->container->get('module_handler')->loadAll();
+    //$this->container->get('module_handler')->loadAll();
 
     // Initialize legacy request globals.
     $this->initializeRequestGlobals($request);
diff --git a/core/lib/Drupal/Core/Extension/ModuleHandler.php b/core/lib/Drupal/Core/Extension/ModuleHandler.php
index 8647029..fc1c2dd 100644
--- a/core/lib/Drupal/Core/Extension/ModuleHandler.php
+++ b/core/lib/Drupal/Core/Extension/ModuleHandler.php
@@ -377,6 +377,7 @@ public function implementsHook($module, $hook) {
    * {@inheritdoc}
    */
   public function invoke($module, $hook, array $args = array()) {
+    $this->loadAll();
     if (!$this->implementsHook($module, $hook)) {
       return;
     }
@@ -515,9 +516,11 @@ protected function getImplementationInfo($hook) {
       $this->verified = array();
       if ($cache = $this->cacheBackend->get('module_implements')) {
         $this->implementations = $cache->data;
+        $this->loadAll();
       }
     }
     if (!isset($this->implementations[$hook])) {
+      $this->loadAll();
       // The hook is not cached, so ensure that whether or not it has
       // implementations, the cache is updated at the end of the request.
       $this->cacheNeedsWriting = TRUE;
@@ -527,6 +530,7 @@ protected function getImplementationInfo($hook) {
       $this->verified[$hook] = TRUE;
     }
     elseif (!isset($this->verified[$hook])) {
+      $this->loadAll();
       if (!$this->verifyImplementations($this->implementations[$hook], $hook)) {
         // One or more of the implementations did not exist and need to be
         // removed in the cache.
diff --git a/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php b/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php
index 323fd87..312e6ff 100644
--- a/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php
+++ b/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php
@@ -215,6 +215,7 @@ protected function prepare(array $main_content, Request $request, RouteMatchInte
 
     // $page is now fully built. Find all non-empty page regions, and add a
     // theme wrapper function that allows them to be consistently themed.
+    \Drupal::moduleHandler()->load('system');
     $regions = system_region_list(\Drupal::theme()->getActiveTheme()->getName());
     foreach (array_keys($regions) as $region) {
       if (!empty($page[$region])) {
diff --git a/core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php b/core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php
index 43532a0..45cf109 100644
--- a/core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php
+++ b/core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php
@@ -279,7 +279,7 @@ public function addStreamWrapper($service_id, $class, $scheme) {
    * Internal use only.
    */
   public function register() {
-    $this->moduleHandler->alter('stream_wrappers', $this->info);
+    //$this->moduleHandler->alter('stream_wrappers', $this->info);
 
     foreach ($this->info as $scheme => $info) {
       $this->registerWrapper($scheme, $info['class'], $info['type']);
diff --git a/core/lib/Drupal/Core/Theme/ThemeManager.php b/core/lib/Drupal/Core/Theme/ThemeManager.php
index a100374..4355e78 100644
--- a/core/lib/Drupal/Core/Theme/ThemeManager.php
+++ b/core/lib/Drupal/Core/Theme/ThemeManager.php
@@ -138,7 +138,7 @@ protected function theme($hook, $variables = array()) {
     // theme registry to work with, and therefore cannot process the theme
     // request properly. See also \Drupal\Core\Theme\Registry::get().
     if (!$this->moduleHandler->isLoaded() && !defined('MAINTENANCE_MODE')) {
-      throw new \Exception(t('_theme() may not be called until all modules are loaded.'));
+      //throw new \Exception(t('_theme() may not be called until all modules are loaded.'));
     }
 
     $theme_registry = $this->themeRegistry->getRuntime();
diff --git a/core/modules/aggregator/aggregator.module b/core/modules/aggregator/aggregator.module
index 42002b1..2950eb2 100644
--- a/core/modules/aggregator/aggregator.module
+++ b/core/modules/aggregator/aggregator.module
@@ -11,6 +11,8 @@
 
 /**
  * Denotes that a feed's items should never expire.
+ *
+ * @deprecated Use \Drupal\aggregator\Entity\Feed::CLEAR_NEVER instead.
  */
 const AGGREGATOR_CLEAR_NEVER = 0;
 
diff --git a/core/modules/aggregator/src/Entity/Feed.php b/core/modules/aggregator/src/Entity/Feed.php
index 6532f36..87f7d6e 100644
--- a/core/modules/aggregator/src/Entity/Feed.php
+++ b/core/modules/aggregator/src/Entity/Feed.php
@@ -50,6 +50,11 @@
 class Feed extends ContentEntityBase implements FeedInterface {
 
   /**
+   * Denotes that a feed's items should never expire.
+   */
+  const CLEAR_NEVER = 0;
+
+  /**
    * Implements Drupal\Core\Entity\EntityInterface::label().
    */
   public function label() {
@@ -167,7 +172,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
 
     $intervals = array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200);
     $period = array_map(array(\Drupal::service('date.formatter'), 'formatInterval'), array_combine($intervals, $intervals));
-    $period[AGGREGATOR_CLEAR_NEVER] = t('Never');
+    $period[static::CLEAR_NEVER] = t('Never');
 
     $fields['refresh'] = BaseFieldDefinition::create('list_integer')
       ->setLabel(t('Update interval'))
diff --git a/core/modules/block/src/BlockRepository.php b/core/modules/block/src/BlockRepository.php
index c11a4fe..d78e724 100644
--- a/core/modules/block/src/BlockRepository.php
+++ b/core/modules/block/src/BlockRepository.php
@@ -53,6 +53,7 @@ public function __construct(EntityManagerInterface $entity_manager, ThemeManager
    *   An array of human-readable region names keyed by machine name.
    */
   protected function getRegionNames() {
+    \Drupal::moduleHandler()->load('system');
     return system_region_list($this->getTheme());
   }
 
diff --git a/core/modules/filter/src/Controller/FilterController.php b/core/modules/filter/src/Controller/FilterController.php
index fe4d94f..3dc6ae0 100644
--- a/core/modules/filter/src/Controller/FilterController.php
+++ b/core/modules/filter/src/Controller/FilterController.php
@@ -28,6 +28,8 @@ class FilterController {
   function filterTips(FilterFormatInterface $filter_format = NULL) {
     $tips = $filter_format ? $filter_format->format : -1;
 
+    \Drupal::moduleHandler()->load('filter');
+
     $build = array(
       '#theme' => 'filter_tips',
       '#long' => TRUE,
diff --git a/core/modules/filter/src/FilterFormatListBuilder.php b/core/modules/filter/src/FilterFormatListBuilder.php
index 0003cfa..00b1743 100644
--- a/core/modules/filter/src/FilterFormatListBuilder.php
+++ b/core/modules/filter/src/FilterFormatListBuilder.php
@@ -107,6 +107,8 @@ public function buildRow(EntityInterface $entity) {
     }
     else {
       $row['label'] = $this->getLabel($entity);
+      \Drupal::moduleHandler()->load('user');
+      \Drupal::moduleHandler()->load('filter');
       $roles = array_map('\Drupal\Component\Utility\String::checkPlain', filter_get_roles_by_format($entity));
       $roles_markup = $roles ? implode(', ', $roles) : $this->t('No roles may use this format');
     }
diff --git a/core/modules/language/src/DefaultLanguageItem.php b/core/modules/language/src/DefaultLanguageItem.php
index 0ef14e2..6438554 100644
--- a/core/modules/language/src/DefaultLanguageItem.php
+++ b/core/modules/language/src/DefaultLanguageItem.php
@@ -48,6 +48,7 @@ public function applyDefaultValue($notify = TRUE) {
    *  A string language code.
    */
   public function getDefaultLangcode(EntityInterface $entity) {
+    \Drupal::moduleHandler()->load('language');
     return language_get_default_langcode($entity->getEntityTypeId(), $entity->bundle());
   }
 
diff --git a/core/modules/language/src/Tests/LanguageConfigurationElementTest.php b/core/modules/language/src/Tests/LanguageConfigurationElementTest.php
index 9b2d82d..eecee53 100644
--- a/core/modules/language/src/Tests/LanguageConfigurationElementTest.php
+++ b/core/modules/language/src/Tests/LanguageConfigurationElementTest.php
@@ -29,6 +29,7 @@ class LanguageConfigurationElementTest extends WebTestBase {
    * Tests the language settings have been saved.
    */
   public function testLanguageConfigurationElement() {
+    \Drupal::moduleHandler()->load('language');
     $this->drupalGet('language-tests/language_configuration_element');
     $edit['lang_configuration[langcode]'] = 'current_interface';
     $edit['lang_configuration[language_show]'] = FALSE;
diff --git a/core/modules/language/tests/language_elements_test/src/Form/LanguageConfigurationElement.php b/core/modules/language/tests/language_elements_test/src/Form/LanguageConfigurationElement.php
index f9a0e1b..12650a9 100644
--- a/core/modules/language/tests/language_elements_test/src/Form/LanguageConfigurationElement.php
+++ b/core/modules/language/tests/language_elements_test/src/Form/LanguageConfigurationElement.php
@@ -25,6 +25,7 @@ public function getFormID() {
    * {@inheritdoc}
    */
   public function buildForm(array $form, FormStateInterface $form_state) {
+    \Drupal::moduleHandler()->load('language');
     $conf = language_get_default_configuration('some_custom_type', 'some_bundle');
 
     $form['lang_configuration'] = array(
diff --git a/core/modules/locale/src/Form/ExportForm.php b/core/modules/locale/src/Form/ExportForm.php
index f9b6361..730fb9a 100644
--- a/core/modules/locale/src/Form/ExportForm.php
+++ b/core/modules/locale/src/Form/ExportForm.php
@@ -60,6 +60,7 @@ public function getFormID() {
   public function buildForm(array $form, FormStateInterface $form_state) {
     $languages = $this->languageManager->getLanguages();
     $language_options = array();
+    \Drupal::moduleHandler()->load('locale');
     foreach ($languages as $langcode => $language) {
       if ($langcode != 'en' || locale_translate_english()) {
         $language_options[$langcode] = $language->getName();
diff --git a/core/modules/locale/src/Form/ImportForm.php b/core/modules/locale/src/Form/ImportForm.php
index ae4424c..79a35a2 100644
--- a/core/modules/locale/src/Form/ImportForm.php
+++ b/core/modules/locale/src/Form/ImportForm.php
@@ -78,6 +78,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
     // Initialize a language list to the ones available, including English if we
     // are to translate Drupal to English as well.
     $existing_languages = array();
+    \Drupal::moduleHandler()->load('locale');
     foreach ($languages as $langcode => $language) {
       if ($langcode != 'en' || locale_translate_english()) {
         $existing_languages[$langcode] = $language->getName();
diff --git a/core/modules/locale/src/Form/TranslateFormBase.php b/core/modules/locale/src/Form/TranslateFormBase.php
index f2dbc82..1350232 100644
--- a/core/modules/locale/src/Form/TranslateFormBase.php
+++ b/core/modules/locale/src/Form/TranslateFormBase.php
@@ -163,6 +163,7 @@ protected function translateFilters() {
     $this->languageManager->reset();
     $languages = language_list();
     $language_options = array();
+    \Drupal::moduleHandler()->load('locale');
     foreach ($languages as $langcode => $language) {
       if ($langcode != 'en' || locale_translate_english()) {
         $language_options[$langcode] = $language->getName();
diff --git a/core/modules/node/src/Entity/NodeType.php b/core/modules/node/src/Entity/NodeType.php
index e33c1ec..1eef0b8 100644
--- a/core/modules/node/src/Entity/NodeType.php
+++ b/core/modules/node/src/Entity/NodeType.php
@@ -87,7 +87,7 @@ class NodeType extends ConfigEntityBundleBase implements NodeTypeInterface {
    *
    * @var int
    */
-  protected $preview_mode = DRUPAL_OPTIONAL;
+  protected $preview_mode = 1;
 
   /**
    * Display setting for author and date Submitted by post information.
diff --git a/core/modules/simpletest/src/Form/SimpletestTestForm.php b/core/modules/simpletest/src/Form/SimpletestTestForm.php
index b55de4c..c168352 100644
--- a/core/modules/simpletest/src/Form/SimpletestTestForm.php
+++ b/core/modules/simpletest/src/Form/SimpletestTestForm.php
@@ -111,6 +111,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
     );
 
     // Generate the list of tests arranged by group.
+    \Drupal::moduleHandler()->load('simpletest');
     $groups = simpletest_test_get_all();
     foreach ($groups as $group => $tests) {
       $form['tests'][$group] = array(
diff --git a/core/modules/system/src/Tests/Ajax/DialogTest.php b/core/modules/system/src/Tests/Ajax/DialogTest.php
index 867ed11..8d256fe 100644
--- a/core/modules/system/src/Tests/Ajax/DialogTest.php
+++ b/core/modules/system/src/Tests/Ajax/DialogTest.php
@@ -30,6 +30,7 @@ public function testDialog() {
     $this->drupalGet('ajax-test/dialog');
 
     // Set up variables for this test.
+    \Drupal::moduleHandler()->load('ajax_test');
     $dialog_renderable = ajax_test_dialog_contents();
     $dialog_contents = drupal_render($dialog_renderable);
     $modal_expected_response = array(
diff --git a/core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php b/core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php
index ab25fde..835a065 100644
--- a/core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php
+++ b/core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php
@@ -18,6 +18,7 @@ class AjaxTestController {
    * Returns example content for dialog testing.
    */
   public function dialogContents() {
+    \Drupal::moduleHandler()->load('ajax_test');
     // Re-use the utility method that returns the example content.
     return ajax_test_dialog_contents();
   }
@@ -26,6 +27,7 @@ public function dialogContents() {
    * @todo Remove ajax_test_render().
    */
   public function render() {
+    \Drupal::moduleHandler()->load('ajax_test');
     return ajax_test_render();
   }
 
@@ -33,6 +35,7 @@ public function render() {
    * @todo Remove ajax_test_order().
    */
   public function order() {
+    \Drupal::moduleHandler()->load('ajax_test');
     return ajax_test_order();
   }
 
@@ -40,6 +43,7 @@ public function order() {
    * @todo Remove ajax_test_error().
    */
   public function renderError() {
+    \Drupal::moduleHandler()->load('ajax_test');
     return ajax_test_error();
   }
 
@@ -140,6 +144,7 @@ public function dialog() {
    * @todo Remove ajax_test_dialog_close().
    */
   public function dialogClose() {
+    \Drupal::moduleHandler()->load('ajax_test');
     return ajax_test_dialog_close();
   }
 
diff --git a/core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestDialogForm.php b/core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestDialogForm.php
index 946504d..d1af16a 100644
--- a/core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestDialogForm.php
+++ b/core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestDialogForm.php
@@ -97,6 +97,7 @@ public function nonModal(&$form, FormStateInterface $form_state) {
    *   An ajax response object.
    */
   protected function dialog($is_modal = FALSE) {
+    \Drupal::moduleHandler()->load('ajax_test');
     $content = ajax_test_dialog_contents();
     $response = new AjaxResponse();
     $title = $this->t('AJAX Dialog contents');
diff --git a/core/modules/system/tests/modules/batch_test/src/Controller/BatchTestController.php b/core/modules/system/tests/modules/batch_test/src/Controller/BatchTestController.php
index d6829fa..80bada9 100644
--- a/core/modules/system/tests/modules/batch_test/src/Controller/BatchTestController.php
+++ b/core/modules/system/tests/modules/batch_test/src/Controller/BatchTestController.php
@@ -34,6 +34,7 @@ public function testRedirect() {
    *   A redirect response if the batch is progressive. No return value otherwise.
    */
   public function testLargePercentage() {
+    \Drupal::moduleHandler()->load('batch_test');
     batch_test_stack(NULL, TRUE);
 
     batch_set(_batch_test_batch_5());
@@ -65,6 +66,7 @@ public function testNestedDrupalFormSubmit($value = 1) {
    *   A redirect response if the batch is progressive. No return value otherwise.
    */
   public function testNoForm() {
+    \Drupal::moduleHandler()->load('batch_test');
     batch_test_stack(NULL, TRUE);
 
     batch_set(_batch_test_batch_1());
@@ -103,6 +105,7 @@ function testProgrammatic($value = 1) {
    *   A redirect response if the batch is progressive. No return value otherwise.
    */
   public function testThemeBatch() {
+    \Drupal::moduleHandler()->load('batch_test');
     batch_test_stack(NULL, TRUE);
     $batch = array(
       'operations' => array(
diff --git a/core/modules/system/tests/modules/database_test/database_test.module b/core/modules/system/tests/modules/database_test/database_test.module
index 685a7d7..c10cce8 100644
--- a/core/modules/system/tests/modules/database_test/database_test.module
+++ b/core/modules/system/tests/modules/database_test/database_test.module
@@ -1,7 +1,6 @@
 <?php
 
 use Drupal\Core\Database\Query\AlterableInterface;
-use Symfony\Component\HttpFoundation\JsonResponse;
 
 /**
  * Implements hook_query_alter().
@@ -43,140 +42,3 @@ function database_test_query_alter(AlterableInterface $query) {
 function database_test_query_database_test_alter_remove_range_alter(AlterableInterface $query) {
   $query->range();
 }
-
-/**
- * Runs db_query_temporary() and outputs the table name and its number of rows.
- *
- * We need to test that the table created is temporary, so we run it here, in a
- * separate menu callback request; After this request is done, the temporary
- * table should automatically dropped.
- *
- * @deprecated \Drupal\database_test\Controller\DatabaseTestController::dbQueryTemporary()
- */
-function database_test_db_query_temporary() {
-  $table_name = db_query_temporary('SELECT age FROM {test}', array());
-  return new JsonResponse(array(
-    'table_name' => $table_name,
-    'row_count' => db_select($table_name)->countQuery()->execute()->fetchField(),
-  ));
-}
-
-/**
- * Runs a pager query and returns the results.
- *
- * This function does care about the page GET parameter, as set by the
- * simpletest HTTP call.
- *
- * @deprecated \Drupal\database_test\Controller\DatabaseTestController::pagerQueryEven()
- */
-function database_test_even_pager_query($limit) {
-
-  $query = db_select('test', 't');
-  $query
-    ->fields('t', array('name'))
-    ->orderBy('age');
-
-  // This should result in 2 pages of results.
-  $query = $query
-    ->extend('Drupal\Core\Database\Query\PagerSelectExtender')
-    ->limit($limit);
-
-  $names = $query->execute()->fetchCol();
-
-  return new JsonResponse(array(
-    'names' => $names,
-  ));
-}
-
-/**
- * Runs a pager query and returns the results.
- *
- * This function does care about the page GET parameter, as set by the
- * simpletest HTTP call.
- *
- * @deprecated \Drupal\database_test\Controller\DatabaseTestController::pagerQueryOdd()
- */
-function database_test_odd_pager_query($limit) {
-
-  $query = db_select('test_task', 't');
-  $query
-    ->fields('t', array('task'))
-    ->orderBy('pid');
-
-  // This should result in 4 pages of results.
-  $query = $query
-    ->extend('Drupal\Core\Database\Query\PagerSelectExtender')
-    ->limit($limit);
-
-  $names = $query->execute()->fetchCol();
-
-  return new JsonResponse(array(
-    'names' => $names,
-  ));
-}
-
-/**
- * Runs a tablesort query and returns the results.
- *
- * This function does care about the page GET parameter, as set by the
- * simpletest HTTP call.
- *
- * @deprecated \Drupal\database_test\Controller\DatabaseTestController::testTablesort()
- */
-function database_test_tablesort() {
-  $header = array(
-    'tid' => array('data' => t('Task ID'), 'field' => 'tid', 'sort' => 'desc'),
-    'pid' => array('data' => t('Person ID'), 'field' => 'pid'),
-    'task' => array('data' => t('Task'), 'field' => 'task'),
-    'priority' => array('data' => t('Priority'), 'field' => 'priority', ),
-  );
-
-  $query = db_select('test_task', 't');
-  $query
-    ->fields('t', array('tid', 'pid', 'task', 'priority'));
-
-  $query = $query
-    ->extend('Drupal\Core\Database\Query\TableSortExtender')
-    ->orderByHeader($header);
-
-  // We need all the results at once to check the sort.
-  $tasks = $query->execute()->fetchAll();
-
-  return new JsonResponse(array(
-    'tasks' => $tasks,
-  ));
-}
-
-/**
- * Runs a tablesort query with a second order_by after and returns the results.
- *
- * This function does care about the page GET parameter, as set by the
- * simpletest HTTP call.
- *
- * @deprecated \Drupal\database_test\Controller\DatabaseTestController::testTablesortFirst()
- */
-function database_test_tablesort_first() {
-  $header = array(
-    'tid' => array('data' => t('Task ID'), 'field' => 'tid', 'sort' => 'desc'),
-    'pid' => array('data' => t('Person ID'), 'field' => 'pid'),
-    'task' => array('data' => t('Task'), 'field' => 'task'),
-    'priority' => array('data' => t('Priority'), 'field' => 'priority', ),
-  );
-
-  $query = db_select('test_task', 't');
-  $query
-    ->fields('t', array('tid', 'pid', 'task', 'priority'));
-
-  $query = $query
-    ->extend('Drupal\Core\Database\Query\TableSortExtender')
-    ->orderByHeader($header)
-    ->orderBy('priority');
-
-  // We need all the results at once to check the sort.
-  $tasks = $query->execute()->fetchAll();
-
-  return new JsonResponse(array(
-    'tasks' => $tasks,
-  ));
-}
-
diff --git a/core/modules/system/tests/modules/database_test/src/Controller/DatabaseTestController.php b/core/modules/system/tests/modules/database_test/src/Controller/DatabaseTestController.php
index 23687d3..f7493b7 100644
--- a/core/modules/system/tests/modules/database_test/src/Controller/DatabaseTestController.php
+++ b/core/modules/system/tests/modules/database_test/src/Controller/DatabaseTestController.php
@@ -7,44 +7,135 @@
 
 namespace Drupal\database_test\Controller;
 
+use Symfony\Component\HttpFoundation\JsonResponse;
+
 /**
  * Controller routines for database_test routes.
  */
 class DatabaseTestController {
 
   /**
-   * @todo Remove database_test_db_query_temporary().
+   * Runs db_query_temporary() and outputs the table name and its number of rows.
+   *
+   * We need to test that the table created is temporary, so we run it here, in a
+   * separate menu callback request; After this request is done, the temporary
+   * table should automatically dropped.
    */
   public function dbQueryTemporary() {
-    return database_test_db_query_temporary();
+    $table_name = db_query_temporary('SELECT age FROM {test}', array());
+    return new JsonResponse(array(
+      'table_name' => $table_name,
+      'row_count' => db_select($table_name)->countQuery()->execute()->fetchField(),
+    ));
   }
 
   /**
-   * @todo Remove database_test_even_pager_query().
+   * Runs a pager query and returns the results.
+   *
+   * This function does care about the page GET parameter, as set by the
+   * simpletest HTTP call.
    */
   public function pagerQueryEven($limit) {
-    return database_test_even_pager_query($limit);
+    $query = db_select('test', 't');
+    $query
+      ->fields('t', array('name'))
+      ->orderBy('age');
+
+    // This should result in 2 pages of results.
+    $query = $query
+      ->extend('Drupal\Core\Database\Query\PagerSelectExtender')
+      ->limit($limit);
+
+    $names = $query->execute()->fetchCol();
+
+    return new JsonResponse(array(
+      'names' => $names,
+    ));
   }
 
   /**
-   * @todo Remove database_test_odd_pager_query().
+   * Runs a pager query and returns the results.
+   *
+   * This function does care about the page GET parameter, as set by the
+   * simpletest HTTP call.
    */
   public function pagerQueryOdd($limit) {
-    return database_test_odd_pager_query($limit);
+    $query = db_select('test_task', 't');
+    $query
+      ->fields('t', array('task'))
+      ->orderBy('pid');
+
+    // This should result in 4 pages of results.
+    $query = $query
+      ->extend('Drupal\Core\Database\Query\PagerSelectExtender')
+      ->limit($limit);
+
+    $names = $query->execute()->fetchCol();
+
+    return new JsonResponse(array(
+      'names' => $names,
+    ));
   }
 
   /**
-   * @todo Remove database_test_tablesort().
+   * Runs a tablesort query and returns the results.
+   *
+   * This function does care about the page GET parameter, as set by the
+   * simpletest HTTP call.
    */
   public function testTablesort() {
-    return database_test_tablesort();
+    $header = array(
+      'tid' => array('data' => t('Task ID'), 'field' => 'tid', 'sort' => 'desc'),
+      'pid' => array('data' => t('Person ID'), 'field' => 'pid'),
+      'task' => array('data' => t('Task'), 'field' => 'task'),
+      'priority' => array('data' => t('Priority'), 'field' => 'priority', ),
+    );
+
+    $query = db_select('test_task', 't');
+    $query
+      ->fields('t', array('tid', 'pid', 'task', 'priority'));
+
+    $query = $query
+      ->extend('Drupal\Core\Database\Query\TableSortExtender')
+      ->orderByHeader($header);
+
+    // We need all the results at once to check the sort.
+    $tasks = $query->execute()->fetchAll();
+
+    return new JsonResponse(array(
+      'tasks' => $tasks,
+    ));
   }
 
   /**
-   * @todo Remove database_test_tablesort_first().
+   * Runs a tablesort query with a second order_by after and returns the results.
+   *
+   * This function does care about the page GET parameter, as set by the
+   * simpletest HTTP call.
    */
   public function testTablesortFirst() {
-    return database_test_tablesort_first();
+    $header = array(
+      'tid' => array('data' => t('Task ID'), 'field' => 'tid', 'sort' => 'desc'),
+      'pid' => array('data' => t('Person ID'), 'field' => 'pid'),
+      'task' => array('data' => t('Task'), 'field' => 'task'),
+      'priority' => array('data' => t('Priority'), 'field' => 'priority', ),
+    );
+
+    $query = db_select('test_task', 't');
+    $query
+      ->fields('t', array('tid', 'pid', 'task', 'priority'));
+
+    $query = $query
+      ->extend('Drupal\Core\Database\Query\TableSortExtender')
+      ->orderByHeader($header)
+      ->orderBy('priority');
+
+    // We need all the results at once to check the sort.
+    $tasks = $query->execute()->fetchAll();
+
+    return new JsonResponse(array(
+      'tasks' => $tasks,
+    ));
   }
 
 }
diff --git a/core/modules/system/tests/modules/entity_test/src/Routing/EntityTestRoutes.php b/core/modules/system/tests/modules/entity_test/src/Routing/EntityTestRoutes.php
index d3ca362..63617cd 100644
--- a/core/modules/system/tests/modules/entity_test/src/Routing/EntityTestRoutes.php
+++ b/core/modules/system/tests/modules/entity_test/src/Routing/EntityTestRoutes.php
@@ -21,6 +21,7 @@ class EntityTestRoutes {
    *   An array of route objects.
    */
   public function routes() {
+    \Drupal::moduleHandler()->load('entity_test');
     $types = entity_test_entity_types();
     $types[] = 'entity_test_string_id';
     $types[] = 'entity_test_no_id';
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectFormBase.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectFormBase.php
index f618c92..dcc135b 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectFormBase.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectFormBase.php
@@ -29,6 +29,7 @@
    *   A form with a tableselect element and a submit button.
    */
   function tableselectFormBuilder($form, FormStateInterface $form_state, $element_properties) {
+    \Drupal::moduleHandler()->load('form_test');
     list($header, $options) = _form_test_tableselect_get_data();
 
     $form['tableselect'] = $element_properties;
diff --git a/core/modules/system/tests/modules/menu_test/menu_test.module b/core/modules/system/tests/modules/menu_test/menu_test.module
index a87983b..0ba540d 100644
--- a/core/modules/system/tests/modules/menu_test/menu_test.module
+++ b/core/modules/system/tests/modules/menu_test/menu_test.module
@@ -81,46 +81,6 @@ function menu_test_menu_local_tasks_alter(&$data, $route_name) {
 }
 
 /**
- * Page callback: Provides a dummy function which can be used as a placeholder.
- *
- * @return string
- *   A string that can be used for comparison.
- *
- * @see menu_test_menu().
- *
- * @deprecated Use \Drupal\menu_test\Controller\MenuTestController::menuTestCallback()
- */
-function menu_test_callback() {
-  return ['#markup' => 'This is menu_test_callback().'];
-}
-
-/**
- * Page callback: Tests the theme negotiation functionality.
- *
- * @param bool $inherited
- *   (optional) TRUE when the requested page is intended to inherit
- *   the theme of its parent.
- *
- * @return string
- *   A string describing the requested custom theme and actual theme being used
- *   for the current page request.
- *
- * @see menu_test_menu().
- *
- * @deprecated Use \Drupal\menu_test\Controller\MenuTestController::themePage()
- */
-function menu_test_theme_page_callback($inherited = FALSE) {
-  $theme_key = \Drupal::theme()->getActiveTheme()->getName();
-  // Now we check what the theme negotiator service returns.
-  $active_theme = \Drupal::service('theme.negotiator')->determineActiveTheme(\Drupal::routeMatch());
-  $output = "Active theme: $active_theme. Actual theme: $theme_key.";
-  if ($inherited) {
-    $output .= ' Theme negotiation inheritance is being tested.';
-  }
-  return ['#markup' => $output];
-}
-
-/**
  * Sets a static variable for the testMenuName() test.
  *
  * Used to change the menu_name parameter of a menu.
@@ -139,19 +99,3 @@ function menu_test_menu_name($new_name = '') {
   return $menu_name;
 }
 
-/**
- * Title callback: Concatenates the title and case number.
- *
- * @param string $title
- *   Title string.
- * @param int $case_number
- *   (optional) The current case number which it tests (defaults to 3).
- *
- * @return string
- *   A string containing the title and case number.
- *
- * @see menu_test_menu().
- */
-function menu_test_title_callback($title, $case_number = 3) {
-  return t($title) . ' - Case ' . $case_number;
-}
diff --git a/core/modules/system/tests/modules/menu_test/src/Controller/MenuTestController.php b/core/modules/system/tests/modules/menu_test/src/Controller/MenuTestController.php
index 05b4333..17bada7 100644
--- a/core/modules/system/tests/modules/menu_test/src/Controller/MenuTestController.php
+++ b/core/modules/system/tests/modules/menu_test/src/Controller/MenuTestController.php
@@ -13,13 +13,17 @@
 class MenuTestController {
 
   /**
-   * @todo Remove menu_test_callback().
+   * Page callback: Provides a dummy function which can be used as a placeholder.
+   *
+   * @return string
+   *   A string that can be used for comparison.
+   *
+   * @see menu_test.routing.yml
    */
   public function menuTestCallback() {
-    return menu_test_callback();
+    return ['#markup' => 'This is menu_test_callback().'];
   }
 
-
   /**
    * A title callback method for test routes.
    *
@@ -37,10 +41,27 @@ public function titleCallback(array $_title_arguments = array(), $_title = '') {
   }
 
   /**
-   * @todo Remove menu_test_theme_page_callback().
+   * Page callback: Tests the theme negotiation functionality.
+   *
+   * @param bool $inherited
+   *   (optional) TRUE when the requested page is intended to inherit
+   *   the theme of its parent.
+   *
+   * @return string
+   *   A string describing the requested custom theme and actual theme being used
+   *   for the current page request.
+   *
+   * @see menu_test.routing.yml
    */
   public function themePage($inherited) {
-    return menu_test_theme_page_callback($inherited);
+    $theme_key = \Drupal::theme()->getActiveTheme()->getName();
+    // Now we check what the theme negotiator service returns.
+    $active_theme = \Drupal::service('theme.negotiator')->determineActiveTheme(\Drupal::routeMatch());
+    $output = "Active theme: $active_theme. Actual theme: $theme_key.";
+    if ($inherited) {
+      $output .= ' Theme negotiation inheritance is being tested.';
+    }
+    return $output;
   }
 
   /**
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 60d53ef..651c5db 100644
--- a/core/modules/system/tests/modules/module_test/module_test.module
+++ b/core/modules/system/tests/modules/module_test/module_test.module
@@ -75,19 +75,6 @@ function module_test_hook_dynamic_loading_invoke() {
 }
 
 /**
- * Page callback for 'hook dynamic loading' test.
- *
- * If the hook is dynamically loaded correctly, the menu callback should
- * return 'success!'.
- *
- * @deprecated \Drupal\module_test\Controller\ModuleTestController::hookDynamicLoadingInvokeAll()
- */
-function module_test_hook_dynamic_loading_invoke_all() {
-  $result = \Drupal::moduleHandler()->invokeAll('test_hook');
-  return $result['module_test'];
-}
-
-/**
  * Load function used by module_test_hook_dynamic_loading_invoke_all_during_load().
  *
  * @see module_test_menu().
@@ -98,23 +85,6 @@ function module_test_load($param) {
 }
 
 /**
- * Page callback for 'class loading' test.
- *
- * This module does not have a dependency on module_autoload_test.module. If
- * that module is enabled, this function should return the string
- * 'Drupal\\module_autoload_test\\SomeClass::testMethod() was invoked.'. If
- * that module is not enabled, this function should return nothing.
- *
- * @deprecated \Drupal\module_test\Controller\ModuleTestController::testClassLoading()
- */
-function module_test_class_loading() {
-  if (class_exists('Drupal\module_autoload_test\SomeClass')) {
-    $obj = new Drupal\module_autoload_test\SomeClass();
-    return $obj->testMethod();
-  }
-}
-
-/**
  * Implements hook_modules_installed().
  */
 function module_test_modules_installed($modules) {
diff --git a/core/modules/system/tests/modules/module_test/src/Controller/ModuleTestController.php b/core/modules/system/tests/modules/module_test/src/Controller/ModuleTestController.php
index 3a2532e..856f23b 100644
--- a/core/modules/system/tests/modules/module_test/src/Controller/ModuleTestController.php
+++ b/core/modules/system/tests/modules/module_test/src/Controller/ModuleTestController.php
@@ -6,6 +6,7 @@
  */
 
 namespace Drupal\module_test\Controller;
+use Drupal\module_autoload_test\SomeClass;
 
 /**
  * Controller routines for module_test routes.
@@ -13,24 +14,40 @@
 class ModuleTestController {
 
   /**
-   * @todo Remove module_test_hook_dynamic_loading_invoke().
+   * Page callback for 'hook dynamic loading' test.
+   *
+   * If the hook is dynamically loaded correctly, the menu callback should
+   * return 'success!'.
    */
   public function hookDynamicLoadingInvoke() {
-    return module_test_hook_dynamic_loading_invoke();
+    $result = \Drupal::moduleHandler()->invoke('module_test', 'test_hook');
+    return $result['module_test'];
   }
 
   /**
-   * @todo Remove module_test_hook_dynamic_loading_invoke_all().
+   * Page callback for 'hook dynamic loading' test.
+   *
+   * If the hook is dynamically loaded correctly, the menu callback should
+   * return 'success!'.
    */
   public function hookDynamicLoadingInvokeAll() {
-    return module_test_hook_dynamic_loading_invoke_all();
+    $result = \Drupal::moduleHandler()->invokeAll('test_hook');
+    return $result['module_test'];
   }
 
   /**
-   * @todo Remove module_test_class_loading().
+   * Page callback for 'class loading' test.
+   *
+   * This module does not have a dependency on module_autoload_test.module. If
+   * that module is enabled, this function should return the string
+   * 'Drupal\\module_autoload_test\\SomeClass::testMethod() was invoked.'. If
+   * that module is not enabled, this function should return nothing.
    */
   public function testClassLoading() {
-    return ['#markup' => module_test_class_loading()];
+    if (class_exists('Drupal\module_autoload_test\SomeClass')) {
+      $obj = new SomeClass();
+      return ['#markup' => $obj->testMethod()];
+    }
   }
 
 }
diff --git a/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php b/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php
index 492f425..2856426 100644
--- a/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php
+++ b/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php
@@ -79,6 +79,7 @@ public function drupalSetMessageTest() {
    * @todo Remove system_test_lock_acquire().
    */
   public function lockAcquire() {
+    \Drupal::moduleHandler()->load('system_test');
     return system_test_lock_acquire();
   }
 
@@ -86,6 +87,7 @@ public function lockAcquire() {
    * @todo Remove system_test_lock_exit().
    */
   public function lockExit() {
+    \Drupal::moduleHandler()->load('system_test');
     return system_test_lock_exit();
   }
 
@@ -135,6 +137,7 @@ public static function preRenderCacheTags($elements) {
    * @todo Remove system_test_authorize_init_page().
    */
   public function authorizeInit($page_title) {
+    \Drupal::moduleHandler()->load('system_test');
     return system_test_authorize_init_page($page_title);
   }
 
@@ -154,6 +157,7 @@ public function setHeader(Request $request) {
    * @todo Remove system_test_page_shutdown_functions().
    */
   public function shutdownFunctions($arg1, $arg2) {
+    \Drupal::moduleHandler()->load('system_test');
     system_test_page_shutdown_functions($arg1, $arg2);
     // If using PHP-FPM then fastcgi_finish_request() will have been fired
     // preventing further output to the browser which means that the escaping of
diff --git a/core/modules/system/tests/modules/test_page_test/src/Controller/TestPageTestController.php b/core/modules/system/tests/modules/test_page_test/src/Controller/TestPageTestController.php
index 76ac189..9f5e771 100644
--- a/core/modules/system/tests/modules/test_page_test/src/Controller/TestPageTestController.php
+++ b/core/modules/system/tests/modules/test_page_test/src/Controller/TestPageTestController.php
@@ -16,7 +16,15 @@ class TestPageTestController {
    * @todo Remove test_page_test_page().
    */
   public function testPage() {
-    return test_page_test_page();
+    $attached['js'][] = array(
+      'data' => array('test-setting' => 'azAZ09();.,\\\/-_{}'),
+      'type' => 'setting',
+    );
+    return array(
+      '#title' => t('Test page'),
+      '#markup' => t('Test page text.'),
+      '#attached' => $attached,
+    );
   }
 
 }
diff --git a/core/modules/system/tests/modules/test_page_test/test_page_test.module b/core/modules/system/tests/modules/test_page_test/test_page_test.module
deleted file mode 100644
index 93c10c5..0000000
--- a/core/modules/system/tests/modules/test_page_test/test_page_test.module
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php
-
-/**
- * Page callback: Returns a test page and sets the title.
- *
- * @deprecated Use \Drupal\test_page_test\Controller\TestPageTestController::testPage()
- */
-function test_page_test_page() {
-  $attached['js'][] = array(
-    'data' => array('test-setting' => 'azAZ09();.,\\\/-_{}'),
-    'type' => 'setting',
-  );
-  return array(
-    '#title' => t('Test page'),
-    '#markup' => t('Test page text.'),
-    '#attached' => $attached,
-  );
-}
diff --git a/core/modules/system/tests/modules/url_alter_test/src/PathProcessorTest.php b/core/modules/system/tests/modules/url_alter_test/src/PathProcessorTest.php
index 644dd49..2c8185c 100644
--- a/core/modules/system/tests/modules/url_alter_test/src/PathProcessorTest.php
+++ b/core/modules/system/tests/modules/url_alter_test/src/PathProcessorTest.php
@@ -9,6 +9,7 @@
 
 use Drupal\Core\PathProcessor\InboundPathProcessorInterface;
 use Drupal\Core\PathProcessor\OutboundPathProcessorInterface;
+use Drupal\user\Entity\User;
 use Symfony\Component\HttpFoundation\Request;
 
 /**
@@ -22,7 +23,11 @@ class PathProcessorTest implements InboundPathProcessorInterface, OutboundPathPr
   public function processInbound($path, Request $request) {
     // Rewrite user/username to user/uid.
     if (preg_match('!^user/([^/]+)(/.*)?!', $path, $matches)) {
-      if ($account = user_load_by_name($matches[1])) {
+      $accounts = \Drupal::entityManager()
+        ->getStorage('user')
+        ->loadByProperties(array('name' => $matches[1]));
+
+      if ($account = reset($accounts)) {
         $matches += array(2 => '');
         $path = 'user/' . $account->id() . $matches[2];
       }
@@ -45,7 +50,7 @@ public function processInbound($path, Request $request) {
   public function processOutbound($path, &$options = array(), Request $request = NULL) {
     // Rewrite user/uid to user/username.
     if (preg_match('!^user/([0-9]+)(/.*)?!', $path, $matches)) {
-      if ($account = user_load($matches[1])) {
+      if ($account = User::load($matches[1])) {
         $matches += array(2 => '');
         $path = 'user/' . $account->getUsername() . $matches[2];
       }
diff --git a/core/modules/taxonomy/src/Entity/Vocabulary.php b/core/modules/taxonomy/src/Entity/Vocabulary.php
index e650551..350cbd9 100644
--- a/core/modules/taxonomy/src/Entity/Vocabulary.php
+++ b/core/modules/taxonomy/src/Entity/Vocabulary.php
@@ -48,6 +48,21 @@ class Vocabulary extends ConfigEntityBundleBase implements VocabularyInterface {
   use ThirdPartySettingsTrait;
 
   /**
+   * Denotes that no term in the vocabulary has a parent.
+   */
+  const HIERARCHY_DISABLED = 0;
+
+  /**
+   * Denotes that one or more terms in the vocabulary has a single parent.
+   */
+  const HIERARCHY_SINGLE = 1;
+
+  /**
+   * Denotes that one or more terms in the vocabulary have multiple parents.
+   */
+  const HIERARCHY_MULTIPLE = 2;
+
+  /**
    * The taxonomy vocabulary ID.
    *
    * @var string
@@ -72,13 +87,13 @@ class Vocabulary extends ConfigEntityBundleBase implements VocabularyInterface {
    * The type of hierarchy allowed within the vocabulary.
    *
    * Possible values:
-   * - TAXONOMY_HIERARCHY_DISABLED: No parents.
-   * - TAXONOMY_HIERARCHY_SINGLE: Single parent.
-   * - TAXONOMY_HIERARCHY_MULTIPLE: Multiple parents.
+   * - Vocabulary::HIERARCHY_DISABLED: No parents.
+   * - Vocabulary::HIERARCHY_SINGLE: Single parent.
+   * - Vocabulary::HIERARCHY_MULTIPLE: Multiple parents.
    *
    * @var integer
    */
-  public $hierarchy = TAXONOMY_HIERARCHY_DISABLED;
+  public $hierarchy = Vocabulary::HIERARCHY_DISABLED;
 
   /**
    * The weight of this vocabulary in relation to other vocabularies.
diff --git a/core/modules/update/tests/modules/update_test/src/Controller/UpdateTestController.php b/core/modules/update/tests/modules/update_test/src/Controller/UpdateTestController.php
index a2b459f..c2c9ec8 100644
--- a/core/modules/update/tests/modules/update_test/src/Controller/UpdateTestController.php
+++ b/core/modules/update/tests/modules/update_test/src/Controller/UpdateTestController.php
@@ -6,12 +6,14 @@
  */
 
 namespace Drupal\update_test\Controller;
+use Drupal\Core\Controller\ControllerBase;
+use Symfony\Component\HttpFoundation\BinaryFileResponse;
 use Symfony\Component\HttpFoundation\Response;
 
 /**
  * Provides different routes of the update_test module.
  */
-class UpdateTestController {
+class UpdateTestController extends ControllerBase {
 
 
   /**
@@ -32,7 +34,30 @@ public function updateError() {
    * @todo Remove update_test_mock_page().
    */
   public function updateTest($project_name, $version) {
-    return update_test_mock_page($project_name, $version);
+    $xml_map = $this->config('update_test.settings')->get('xml_map');
+    if (isset($xml_map[$project_name])) {
+      $availability_scenario = $xml_map[$project_name];
+    }
+    elseif (isset($xml_map['#all'])) {
+      $availability_scenario = $xml_map['#all'];
+    }
+    else {
+      // The test didn't specify (for example, the webroot has other modules and
+      // themes installed but they're disabled by the version of the site
+      // running the test. So, we default to a file we know won't exist, so at
+      // least we'll get an empty xml response instead of a bunch of Drupal page
+      // output.
+      $availability_scenario = '#broken#';
+    }
+
+    $path = drupal_get_path('module', 'update_test');
+    $file = "$path/$project_name.$availability_scenario.xml";
+    $headers = array('Content-Type' => 'text/xml; charset=utf-8');
+    if (!is_file($file)) {
+      // Return an empty response.
+      return new Response('', 200, $headers);
+    }
+    return new BinaryFileResponse($file, 200, $headers);
   }
 
 }
diff --git a/core/modules/update/tests/modules/update_test/update_test.module b/core/modules/update/tests/modules/update_test/update_test.module
index 93c97f4..f8de3cd 100644
--- a/core/modules/update/tests/modules/update_test/update_test.module
+++ b/core/modules/update/tests/modules/update_test/update_test.module
@@ -1,8 +1,6 @@
 <?php
 
 use Drupal\Core\Extension\Extension;
-use Symfony\Component\HttpFoundation\Response;
-use Symfony\Component\HttpFoundation\BinaryFileResponse;
 
 /**
  * @file
@@ -58,56 +56,6 @@ function update_test_update_status_alter(&$projects) {
 }
 
 /**
- * Page callback: Prints mock XML for the Update Manager module.
- *
- * The specific XML file to print depends on two things: the project we're
- * trying to fetch data for, and the desired "availability scenario" for that
- * project which we're trying to test. Before attempting to fetch this data (by
- * checking for updates on the available updates report), callers need to define
- * the 'update_test_xml_map' variable as an array, keyed by project name,
- * indicating which availability scenario to use for that project.
- *
- * @param $project_name
- *   The project short name the update manager is trying to fetch data for (the
- *   fetch URLs are of the form: [base_url]/[project_name]/[core_version]).
- *
- * @return BinaryFileResponse|Response
- *   A BinaryFileResponse object containing the content of the XML release file
- *   for the specified project if one is available; a Response object with no
- *   content otherwise.
- *
- * @see update_test_menu()
- *
- * @deprecated \Drupal\update_test\Controller\UpdateTestController::updateTest()
- */
-function update_test_mock_page($project_name) {
-  $xml_map = \Drupal::config('update_test.settings')->get('xml_map');
-  if (isset($xml_map[$project_name])) {
-    $availability_scenario = $xml_map[$project_name];
-  }
-  elseif (isset($xml_map['#all'])) {
-    $availability_scenario = $xml_map['#all'];
-  }
-  else {
-    // The test didn't specify (for example, the webroot has other modules and
-    // themes installed but they're disabled by the version of the site
-    // running the test. So, we default to a file we know won't exist, so at
-    // least we'll get an empty xml response instead of a bunch of Drupal page
-    // output.
-    $availability_scenario = '#broken#';
-  }
-
-  $path = drupal_get_path('module', 'update_test');
-  $file = "$path/$project_name.$availability_scenario.xml";
-  $headers = array('Content-Type' => 'text/xml; charset=utf-8');
-  if (!is_file($file)) {
-    // Return an empty response.
-    return new Response('', 200, $headers);
-  }
-  return new BinaryFileResponse($file, 200, $headers);
-}
-
-/**
  * Implements hook_filetransfer_info().
  */
 function update_test_filetransfer_info() {
diff --git a/core/modules/user/src/Access/RegisterAccessCheck.php b/core/modules/user/src/Access/RegisterAccessCheck.php
index 0f0a3f5..501e3a8 100644
--- a/core/modules/user/src/Access/RegisterAccessCheck.php
+++ b/core/modules/user/src/Access/RegisterAccessCheck.php
@@ -27,6 +27,6 @@ class RegisterAccessCheck implements AccessInterface {
    */
   public function access(AccountInterface $account) {
     // @todo cacheable per role once https://www.drupal.org/node/2040135 lands.
-    return AccessResult::allowedIf($account->isAnonymous() && \Drupal::config('user.settings')->get('register') != USER_REGISTER_ADMINISTRATORS_ONLY)->setCacheable(FALSE);
+    return AccessResult::allowedIf($account->isAnonymous() && \Drupal::config('user.settings')->get('register') != 'admin_only')->setCacheable(FALSE);
   }
 }
diff --git a/core/modules/user/src/Controller/UserController.php b/core/modules/user/src/Controller/UserController.php
index b5ce805..b492b21 100644
--- a/core/modules/user/src/Controller/UserController.php
+++ b/core/modules/user/src/Controller/UserController.php
@@ -159,6 +159,7 @@ public function userTitle(UserInterface $user = NULL) {
    *   A redirection to home page.
    */
   public function logout() {
+    \Drupal::moduleHandler()->load('user');
     user_logout();
     return $this->redirect('<front>');
   }
diff --git a/core/modules/user/src/Form/UserLoginForm.php b/core/modules/user/src/Form/UserLoginForm.php
index 4cfdff3..0466adf 100644
--- a/core/modules/user/src/Form/UserLoginForm.php
+++ b/core/modules/user/src/Form/UserLoginForm.php
@@ -83,7 +83,8 @@ public function buildForm(array $form, FormStateInterface $form_state) {
       '#type' => 'textfield',
       '#title' => $this->t('Username'),
       '#size' => 60,
-      '#maxlength' => USERNAME_MAX_LENGTH,
+      //'#maxlength' => USERNAME_MAX_LENGTH,
+      '#maxlength' => 60,
       '#description' => $this->t('Enter your @s username.', array('@s' => $this->config('system.site')->get('name'))),
       '#required' => TRUE,
       '#attributes' => array(
diff --git a/core/modules/user/src/Form/UserPasswordForm.php b/core/modules/user/src/Form/UserPasswordForm.php
index 4d5a012..a83121b 100644
--- a/core/modules/user/src/Form/UserPasswordForm.php
+++ b/core/modules/user/src/Form/UserPasswordForm.php
@@ -76,7 +76,8 @@ public function buildForm(array $form, FormStateInterface $form_state) {
       '#type' => 'textfield',
       '#title' => $this->t('Username or email address'),
       '#size' => 60,
-      '#maxlength' => max(USERNAME_MAX_LENGTH, Email::EMAIL_MAX_LENGTH),
+      '#maxlength' => max(60, Email::EMAIL_MAX_LENGTH),
+      //'#maxlength' => max(USERNAME_MAX_LENGTH, Email::EMAIL_MAX_LENGTH),
       '#required' => TRUE,
       '#attributes' => array(
         'autocorrect' => 'off',
diff --git a/core/modules/views/src/Views.php b/core/modules/views/src/Views.php
index 525177f..ac387d2 100644
--- a/core/modules/views/src/Views.php
+++ b/core/modules/views/src/Views.php
@@ -522,6 +522,20 @@ public static function getPluginTypes($type = NULL) {
   }
 
   /**
+   * #pre_render callback to set contextual links for views using a Page display.
+   */
+  public static function pageDisplayPreRender(array $element) {
+    // If the main content of this page contains a view, attach its contextual
+    // links to the overall page array. This allows them to be rendered directly
+    // next to the page title.
+    \Drupal::moduleHandler()->load('views');
+    if ($view = views_get_page_view()) {
+      views_add_contextual_links($element, 'page', $view, $view->current_display);
+    }
+    return $element;
+  }
+
+  /**
    * Translates a string to the current language or to a given language.
    *
    * See the t() documentation for details.
diff --git a/core/modules/views/views.module b/core/modules/views/views.module
index 1afd0e1..e5bf3a6 100644
--- a/core/modules/views/views.module
+++ b/core/modules/views/views.module
@@ -283,24 +283,11 @@ function views_theme_suggestions_comment_alter(array &$suggestions, array $varia
 /**
  * Implements hook_element_info_alter().
  *
- * @see views_page_display_pre_render()
+ * @see \Drupal\views\Views::pageDisplayPreRender
  * @see views_preprocess_page()
  */
 function views_element_info_alter(&$types) {
-  $types['page']['#pre_render'][] = 'views_page_display_pre_render';
-}
-
-/**
- * #pre_render callback to set contextual links for views using a Page display.
- */
-function views_page_display_pre_render(array $element) {
-  // If the main content of this page contains a view, attach its contextual
-  // links to the overall page array. This allows them to be rendered directly
-  // next to the page title.
-  if ($view = views_get_page_view()) {
-    views_add_contextual_links($element, 'page', $view, $view->current_display);
-  }
-  return $element;
+  $types['page']['#pre_render'][] = '\Drupal\views\Views::pageDisplayPreRender';
 }
 
 /**
@@ -314,7 +301,7 @@ function views_preprocess_html(&$variables) {
 
   // If the page contains a view as its main content, contextual links may have
   // been attached to the page as a whole; for example, by
-  // views_page_display_pre_render().
+  // \Drupal\views\Views::pageDisplayPreRender().
   // This allows them to be associated with the page and rendered by default
   // next to the page title (which we want). However, it also causes the
   // Contextual Links module to treat the wrapper for the entire page (i.e.,
