From faba05fccc9befe73e7477ecd0e9f08ba32aef18 Mon Sep 17 00:00:00 2001
From: Katherine Bailey <katherine@katbailey.net>
Date: Sun, 22 Jul 2012 16:40:08 -0700
Subject: [PATCH] Cleaning up _current_path() and request() related stuff

---
 core/includes/bootstrap.inc                             | 3 +++
 core/includes/path.inc                                  | 3 +++
 core/lib/Drupal/Core/EventSubscriber/PathSubscriber.php | 6 ------
 core/modules/language/language.negotiation.inc          | 4 +++-
 core/modules/user/user.pages.inc                        | 1 -
 index.php                                               | 5 -----
 6 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc
index de35c1f311bd..71a03a6eb93b 100644
--- a/core/includes/bootstrap.inc
+++ b/core/includes/bootstrap.inc
@@ -1632,6 +1632,9 @@ function request(Request $new_request = NULL) {
   if ($new_request) {
     $request = $new_request;
   }
+  elseif (drupal_container()->has('request')) {
+    $request = drupal_container()->get('request');
+  }
   return $request;
 }
 
diff --git a/core/includes/path.inc b/core/includes/path.inc
index 9bb7a969c682..c387de58b918 100644
--- a/core/includes/path.inc
+++ b/core/includes/path.inc
@@ -358,6 +358,9 @@ function drupal_match_path($path, $patterns) {
  * @see request_path()
  */
 function current_path() {
+  if (drupal_container()->has('request')) {
+    return drupal_container()->get('request')->attributes->get('system_path');
+  }
   return _current_path();
 }
 
diff --git a/core/lib/Drupal/Core/EventSubscriber/PathSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/PathSubscriber.php
index 4902b425dfdf..7688107ce30d 100644
--- a/core/lib/Drupal/Core/EventSubscriber/PathSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/PathSubscriber.php
@@ -69,9 +69,6 @@ public function onKernelRequestFrontPageResolve(GetResponseEvent $event) {
    *   The Event to process.
    */
   public function onKernelRequestLanguageResolve(GetResponseEvent $event) {
-    $request = $event->getRequest();
-    $path = $this->extractPath($request);
-
     // drupal_language_initialize() combines:
     // - Determination of language from $request information (e.g., path).
     // - Determination of language from other information (e.g., site default).
@@ -81,9 +78,6 @@ public function onKernelRequestLanguageResolve(GetResponseEvent $event) {
     //   prior to front page and alias resolution. When above is decoupled, also
     //   add 'langcode' (determined from $request only) to $request->attributes.
     drupal_language_initialize();
-    $path = _current_path();
-
-    $this->setPath($request, $path);
   }
 
   /**
diff --git a/core/modules/language/language.negotiation.inc b/core/modules/language/language.negotiation.inc
index bc6e76727432..78f958b2ff4b 100644
--- a/core/modules/language/language.negotiation.inc
+++ b/core/modules/language/language.negotiation.inc
@@ -225,7 +225,9 @@ function language_from_url($languages, $args = array()) {
       }
 
       list($language, $path) = language_url_split_prefix($current_path, $languages);
-      _current_path($path);
+      if ($request) {
+        $request->attributes->set('system_path', $path);
+      }
       if ($language !== FALSE) {
         $language_url = $language->langcode;
       }
diff --git a/core/modules/user/user.pages.inc b/core/modules/user/user.pages.inc
index 3e347054cdf2..0884df0d8649 100644
--- a/core/modules/user/user.pages.inc
+++ b/core/modules/user/user.pages.inc
@@ -499,7 +499,6 @@ function user_page() {
   if ($user->uid) {
     // @todo: Cleaner sub request handling.
     $subrequest = Request::create('/user/' . $user->uid, 'GET', request()->query->all(), request()->cookies->all(), array(), request()->server->all());
-    request($subrequest);
     return drupal_container()->get('http_kernel')->handle($subrequest, HttpKernelInterface::SUB_REQUEST);
   }
   else {
diff --git a/index.php b/index.php
index 200a2de93c39..15ce17516b0c 100644
--- a/index.php
+++ b/index.php
@@ -25,11 +25,6 @@
 // Create a request object from the HTTPFoundation.
 $request = Request::createFromGlobals();
 
-// Set the global $request object. This is a temporary measure to keep legacy
-// utility functions working. It should be moved to a dependency injection
-// container at some point.
-request($request);
-
 // Bootstrap all of Drupal's subsystems, but do not initialize anything that
 // depends on the fully resolved Drupal path, because path resolution happens
 // during the REQUEST event of the kernel.
-- 
GitLab