diff --git a/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php b/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php
index 0bc4d67..bfa19a3 100644
--- a/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php
+++ b/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php
@@ -41,5 +41,4 @@ public function addObjectResource($object) {
   public function set($id, $service, $scope = self::SCOPE_CONTAINER) {
     Container::set($id, $service, $scope);
   }
-
 }
diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php
index 8651134..f713c58 100644
--- a/core/lib/Drupal/Core/DrupalKernel.php
+++ b/core/lib/Drupal/Core/DrupalKernel.php
@@ -17,6 +17,8 @@
 use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
 use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
 use Symfony\Component\HttpKernel\Kernel;
+use Symfony\Component\HttpKernel\HttpKernelInterface;
+use Symfony\Component\HttpFoundation\Request;
 
 /**
  * The DrupalKernel class is the core of Drupal itself.
@@ -158,6 +160,42 @@ public function boot() {
   }
 
   /**
+   * Overrides Symfony\Component\HttpKernel\HttpKernel::handle().
+   */
+  public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) {
+    $previous_request = $this->container->has('request') ? $this->container->get('request') : NULL;
+
+    try {
+      $request->overrideGlobals();
+      $result = parent::handle($request, $type, $catch);
+    }
+    catch (\Exception $e) {
+      // Handled below.
+    }
+
+    if ($previous_request) {
+      $previous_request->overrideGlobals();
+    }
+    else {
+      $this->clearGlobals();
+    }
+
+    if (isset($e)) {
+      throw $e;
+    }
+    else {
+      return $result;
+    }
+  }
+
+  protected function clearGlobals() {
+    $_GET = array();
+    $_POST = array();
+    $_SERVER = array();
+    $_COOKIE = array();
+  }
+
+  /**
    * Returns an array of available bundles.
    *
    * @return array
