diff --git a/core/lib/Drupal/Core/Extension/Extension.php b/core/lib/Drupal/Core/Extension/Extension.php
index 3c765fe..e1e9b3d 100644
--- a/core/lib/Drupal/Core/Extension/Extension.php
+++ b/core/lib/Drupal/Core/Extension/Extension.php
@@ -166,8 +166,9 @@ public function __call($method, array $args) {
    * Serializes the Extension object in the most optimized way.
    */
   public function serialize() {
+    // Don't serialize the app root, since this could change if the install is
+    // moved..
     $data = array(
-      'root' => $this->root,
       'type' => $this->type,
       'pathname' => $this->pathname,
       'filename' => $this->filename,
@@ -188,7 +189,8 @@ public function serialize() {
    */
   public function unserialize($data) {
     $data = unserialize($data);
-    $this->root = $data['root'];
+    // Get the app root from the container.
+    $this->root = DRUPAL_ROOT;
     $this->type = $data['type'];
     $this->pathname = $data['pathname'];
     $this->filename = $data['filename'];
diff --git a/core/lib/Drupal/Core/Update/UpdateKernel.php b/core/lib/Drupal/Core/Update/UpdateKernel.php
index 6c5de73..04c4668 100755
--- a/core/lib/Drupal/Core/Update/UpdateKernel.php
+++ b/core/lib/Drupal/Core/Update/UpdateKernel.php
@@ -10,10 +10,13 @@
 use Drupal\Core\DrupalKernel;
 use Drupal\Core\Session\AnonymousUserSession;
 use Drupal\Core\Site\Settings;
+use Drupal\system\Tests\Routing\MockRouteProvider;
 use Symfony\Cmf\Component\Routing\RouteObjectInterface;
 use Symfony\Component\HttpFoundation\ParameterBag;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
+use Symfony\Component\Routing\Route;
+use Symfony\Component\Routing\RouteCollection;
 
 /**
  * Defines a kernel which is used primarily to run the update of Drupal.
@@ -57,6 +60,26 @@ public function handle(Request $request, $type = self::MASTER_REQUEST, $catch =
   }
 
   /**
+   * {@inheritdoc}
+   */
+  protected function initializeContainer() {
+    $container = parent::initializeContainer();
+
+    $routes = new RouteCollection();
+
+    $routes->add('<front>', new Route('/', ['_title' => 'Home'], ['_access' => 'TRUE']));
+    $routes->add('<none>', new Route('', [], ['_access' => 'TRUE'], ['_no_path' => TRUE]));
+    $routes->add('<current>', new Route('<current>'));
+    $routes->add('system.db_update', new Route('/update.php/{op}', ['op' => 'info'], ['_access' => 'TRUE']));
+
+    $mock_route_provider = new MockRouteProvider($routes);
+    $container->set('@router.route_provider', $mock_route_provider);
+
+    return $container;
+  }
+
+
+  /**
    * Generates the actual result of update.php.
    *
    * The actual logic of the update is done in the db update controller.
diff --git a/core/modules/block/src/Tests/Update/BlockContextMappingUpdateTest.php b/core/modules/block/src/Tests/Update/BlockContextMappingUpdateTest.php
index da03fa0..582a8e1 100644
--- a/core/modules/block/src/Tests/Update/BlockContextMappingUpdateTest.php
+++ b/core/modules/block/src/Tests/Update/BlockContextMappingUpdateTest.php
@@ -32,7 +32,10 @@ protected function setUp() {
     $this->databaseDumpFiles = [
       __DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
       __DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.block-context-manager-2354889.php',
+      __DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.language-enabled.php',
+      __DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.block-test-enabled.php',
     ];
+
     parent::setUp();
   }
 
diff --git a/core/modules/system/src/Controller/DbUpdateController.php b/core/modules/system/src/Controller/DbUpdateController.php
index 28ab72b..cde11f7 100644
--- a/core/modules/system/src/Controller/DbUpdateController.php
+++ b/core/modules/system/src/Controller/DbUpdateController.php
@@ -210,9 +210,7 @@ protected function info(Request $request) {
     );
 
     $info[] = $this->t("<strong>Back up your code</strong>. Hint: when backing up module code, do not leave that backup in the 'modules' or 'sites/*/modules' directories as this may confuse Drupal's auto-discovery mechanism.");
-    $info[] = $this->t('Put your site into <a href="@url">maintenance mode</a>.', array(
-      '@url' => Url::fromRoute('system.site_maintenance_mode')->toString(TRUE)->getGeneratedUrl(),
-    ));
+    $info[] = $this->t('Put your site into maintenance mode.');
     $info[] = $this->t('<strong>Back up your database</strong>. This process will change your database values and in case of emergency you may need to revert to a backup.');
     $info[] = $this->t('Install your new files in the appropriate location, as described in the handbook.');
     $build['info'] = array(
@@ -228,7 +226,7 @@ protected function info(Request $request) {
       '#type' => 'link',
       '#title' => $this->t('Continue'),
       '#attributes' => array('class' => array('button', 'button--primary')),
-      '#url' => Url::fromUri($request->getUriForPath('/selection')),
+      '#url' => Url::fromUri('base://selection'),
     );
     return $build;
   }
@@ -484,7 +482,7 @@ protected function results(Request $request) {
    */
   public function requirements($severity, array $requirements, Request $request) {
     $options = $severity == REQUIREMENT_WARNING ? array('continue' => 1) : array();
-    $try_again_url = Url::fromUri($request->getUriForPath(''))->setOptions(['query' => $options])->toString(TRUE)->getGeneratedUrl();
+    $try_again_url = Url::fromUri('base://')->setOptions(['query' => $options])->toString(TRUE)->getGeneratedUrl();
 
     $build['status_report'] = array(
       '#theme' => 'status_report',
@@ -580,7 +578,7 @@ protected function triggerBatch(Request $request) {
     );
     batch_set($batch);
 
-    return batch_process(Url::fromUri($request->getUriForPath('/results')), Url::fromUri($request->getUriForPath('/start')));
+    return batch_process(Url::fromUri('base://results'), Url::fromUri('base://start'));
   }
 
   /**
diff --git a/core/modules/system/src/Tests/Update/UpdatePathTestBase.php b/core/modules/system/src/Tests/Update/UpdatePathTestBase.php
index d3d103d..dd22488 100644
--- a/core/modules/system/src/Tests/Update/UpdatePathTestBase.php
+++ b/core/modules/system/src/Tests/Update/UpdatePathTestBase.php
@@ -173,9 +173,6 @@ protected function setUp() {
     // Add the config directories to settings.php.
     drupal_install_config_directories();
 
-    // Install any additional modules.
-    $this->installModulesFromClassProperty($container);
-
     // Restore the original Simpletest batch.
     $this->restoreBatch();
 
@@ -183,6 +180,7 @@ protected function setUp() {
     $this->rebuildAll();
 
     // Replace User 1 with the user created here.
+    // @todo: do this without saving the user account.
     /** @var \Drupal\user\UserInterface $account */
     $account = User::load(1);
     $account->setPassword($this->rootUser->pass_raw);
@@ -260,7 +258,9 @@ protected function rebuildAll() {
     // We know the rebuild causes notices, so don't exit on failure.
     $die_on_fail = $this->dieOnFail;
     $this->dieOnFail = FALSE;
-    parent::rebuildAll();
+
+    // Initialize the container. parent::rebuildall() is not safe to call here.
+    $this->container = \Drupal::getContainer();
 
     // Remove the notices we get due to the menu link rebuild prior to running
     // the system updates for the schema change.
diff --git a/core/modules/system/src/Tests/Update/UpdatePathTestBaseTest.php b/core/modules/system/src/Tests/Update/UpdatePathTestBaseTest.php
index fb01ecf..fa2b96b 100644
--- a/core/modules/system/src/Tests/Update/UpdatePathTestBaseTest.php
+++ b/core/modules/system/src/Tests/Update/UpdatePathTestBaseTest.php
@@ -25,7 +25,10 @@ class UpdatePathTestBaseTest extends UpdatePathTestBase {
    * {@inheritdoc}
    */
   protected function setUp() {
-    $this->databaseDumpFiles = [__DIR__ . '/../../../tests/fixtures/update/drupal-8.bare.standard.php.gz'];
+    $this->databaseDumpFiles = [
+      __DIR__ . '/../../../tests/fixtures/update/drupal-8.bare.standard.php.gz',
+      __DIR__ . '/../../../tests/fixtures/update/drupal-8.update-test-schema-enabled.php',
+    ];
     parent::setUp();
   }
 
diff --git a/core/modules/system/system.install b/core/modules/system/system.install
index ce06b7a..653cb5a 100644
--- a/core/modules/system/system.install
+++ b/core/modules/system/system.install
@@ -1265,6 +1265,9 @@ function system_update_8004() {
   // ensure they match the currently expected status.
   $manager = \Drupal::entityDefinitionUpdateManager();
   foreach (array_keys(\Drupal::entityManager()->getDefinitions()) as $entity_type_id) {
+    if (is_null($manager->getEntityType($entity_type_id))) {
+      $manager->getEntityType($entity_type_id);
+    }
     $manager->updateEntityType($manager->getEntityType($entity_type_id));
   }
 }
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index 865e101..e07fa56 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -249,7 +249,7 @@ function system_theme_suggestions_html(array $variables) {
     $path_args = [''];
   }
   else {
-    $path_args = explode('/', Url::fromRoute('<current>')->getInternalPath());
+    $path_args = explode('/', ltrim(\Drupal::service('path.current')->getPath(), '/'));
   }
   return theme_get_suggestions($path_args, 'html');
 }
diff --git a/core/modules/system/tests/fixtures/update/drupal-8.block-test-enabled.php b/core/modules/system/tests/fixtures/update/drupal-8.block-test-enabled.php
new file mode 100644
index 0000000..d26b379
--- /dev/null
+++ b/core/modules/system/tests/fixtures/update/drupal-8.block-test-enabled.php
@@ -0,0 +1,36 @@
+<?php
+
+/**
+ * @file
+ * Partial database to mimic the installation of the update_test_schema module.
+ */
+
+use Drupal\Core\Database\Database;
+
+$connection = Database::getConnection();
+
+// Set the schema version.
+$connection->insert('key_value')
+  ->fields([
+    'collection' => 'system.schema',
+    'name' => 'block_test',
+    'value' => 'i:8000;',
+  ])
+  ->execute();
+
+// Update core.extension.
+$extensions = $connection->select('config')
+  ->fields('config', ['data'])
+  ->condition('collection', '')
+  ->condition('name', 'core.extension')
+  ->execute()
+  ->fetchField();
+$extensions = unserialize($extensions);
+$extensions['module']['block_test'] = 8000;
+$connection->update('config')
+  ->fields([
+    'data' => serialize($extensions),
+  ])
+  ->condition('collection', '')
+  ->condition('name', 'core.extension')
+  ->execute();
diff --git a/core/modules/system/tests/fixtures/update/drupal-8.language-enabled.php b/core/modules/system/tests/fixtures/update/drupal-8.language-enabled.php
new file mode 100644
index 0000000000000000000000000000000000000000..2306ade0eb6eaed5916093edf4618fc0cfee4dfd
GIT binary patch
literal 5336
zcmeHL-%s2|5Y97yg>{N#QU#9VNJ@PTRSJpv5Va4a>H|d9p1qhAd$zS+Qz+tp?>94R
zpYH-mY11~X@`QJHc7A;G&FpaBepjE@8yjt-qa)YW%AOupPM;nrujZ;*e#|yD9%ofq
z>dc#}j9x^YM3NNRAND7kParuSN5|Sn{#-{*cCHsHy40@0z3rirtpigw+WF1+LSLts
z%C<UwvJpjF2WLjxyxBa#B8uXyvR2H-(Tjs9Zmt`z7u%vaekwwxT4*`8sw`Sn=<Y-m
z^G%cN@9gZ%_~f0K(pNfbz3$xpxz3f>Q3edQ^_ACU@VftQ5c&X!t%F9BbDQw8JTt{=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VFSF{TN$E=d)g)#*gs+xwSexK+rZnw^?
zr9qr7T-DaB8d3M;A|<>j?+Oc{WAmf&N#i4|rEJkzd#ewK5-%~g1-R}p$Fb8$t(1L4
zg&2hpZvn=xXy&OoZB5Fo0Rq&Gm^ISOvud%Z$`r$b#$%ijvG8g`xuiR2;U3PzLK>|1
zxC8dC_R;4>#;bzQ``KaIBcAlY4=19O3`j9a8XyH`D6^7y>RCv<P-eg@3g|XoPLBNq
z{BKNrT^kdiFugR|d(=ep4^MqGXmG9uE-+=JNd9jF;BzVtP=0Ly1U0+9N5O+Y^as#<
z2ICwOaW7doQx6{L5ZC&MA>D!gXP{BKYq0o7oH@y6q!IkFscx5G#)ZLHhA@UNKrkqO
z?wia0+rv$GhQ2)e{Vzj*;n}BQGq5x2=t(~mE&2I?Cz3MrWf1tB2LTifUM2i~k=)z+
OKE*IF_#J654g3yxd%#Hm

literal 0
HcmV?d00001

diff --git a/core/modules/system/tests/fixtures/update/drupal-8.update-test-schema-enabled.php b/core/modules/system/tests/fixtures/update/drupal-8.update-test-schema-enabled.php
new file mode 100644
index 0000000..16042a4
--- /dev/null
+++ b/core/modules/system/tests/fixtures/update/drupal-8.update-test-schema-enabled.php
@@ -0,0 +1,52 @@
+<?php
+
+/**
+ * @file
+ * Partial database to mimic the installation of the update_test_schema module.
+ */
+
+use Drupal\Core\Database\Database;
+
+$connection = Database::getConnection();
+
+// Create the table.
+$connection->schema()->createTable('update_test_schema_table', array(
+  'fields' => array(
+    'a' => array(
+      'type' => 'int',
+      'not null' => TRUE,
+      'size' => 'normal',
+    ),
+    'b' => array(
+      'type' => 'blob',
+      'not null' => FALSE,
+      'size' => 'normal',
+    ),
+  ),
+));
+
+// Set the schema version.
+$connection->insert('key_value')
+  ->fields([
+    'collection' => 'system.schema',
+    'name' => 'update_test_schema',
+    'value' => 'i:8000;',
+  ])
+  ->execute();
+
+// Update core.extension.
+$extensions = $connection->select('config')
+  ->fields('config', ['data'])
+  ->condition('collection', '')
+  ->condition('name', 'core.extension')
+  ->execute()
+  ->fetchField();
+$extensions = unserialize($extensions);
+$extensions['module']['update_test_schema'] = 8000;
+$connection->update('config')
+  ->fields([
+    'data' => serialize($extensions),
+  ])
+  ->condition('collection', '')
+  ->condition('name', 'core.extension')
+  ->execute();
