From a62c75ed68f2fd742e3a82bbb932c9bff5a2085f Mon Sep 17 00:00:00 2001
From: catch <catch@35733.no-reply.drupal.org>
Date: Mon, 28 Jan 2013 13:47:00 +0000
Subject: [PATCH] Issue #1893372 by Crell: Move legacy flag for routes earlier
 in the process.

---
 .../Core/EventSubscriber/LegacyControllerSubscriber.php     | 6 ------
 core/lib/Drupal/Core/LegacyUrlMatcher.php                   | 6 ++++++
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/core/lib/Drupal/Core/EventSubscriber/LegacyControllerSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/LegacyControllerSubscriber.php
index 7009eff9154e..f88fa0e71e56 100644
--- a/core/lib/Drupal/Core/EventSubscriber/LegacyControllerSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/LegacyControllerSubscriber.php
@@ -42,12 +42,6 @@ public function onKernelControllerLegacy(FilterControllerEvent $event) {
 
     // This BC logic applies only to functions. Otherwise, skip it.
     if (is_string($controller) && function_exists($controller)) {
-      // Flag this as a legacy request.  We need to use this for subrequest
-      // handling so that we can treat older page callbacks and new routes
-      // differently.
-      // @todo Remove this line as soon as possible.
-      $request->attributes->set('_legacy', TRUE);
-
       $new_controller = function() use ($router_item) {
         return call_user_func_array($router_item['page_callback'], $router_item['page_arguments']);
       };
diff --git a/core/lib/Drupal/Core/LegacyUrlMatcher.php b/core/lib/Drupal/Core/LegacyUrlMatcher.php
index c1175abdc4c9..7098b412ee66 100644
--- a/core/lib/Drupal/Core/LegacyUrlMatcher.php
+++ b/core/lib/Drupal/Core/LegacyUrlMatcher.php
@@ -111,6 +111,12 @@ public function matchRequest(Request $request) {
         require_once DRUPAL_ROOT . '/' . $router_item['include_file'];
       }
 
+      // Flag this as a legacy request.  We need to use this for subrequest
+      // handling so that we can treat older page callbacks and new routes
+      // differently.
+      // @todo Remove this line as soon as possible.
+      $ret['_legacy'] = TRUE;
+
       return $ret;
     }
 
-- 
GitLab