瀏覽代碼

merged branch stof/subrequest_fix (PR #2208)

Commits
-------

ab8e760 Fixed the creation of the subrequests

Discussion
----------

Fixed the creation of the subrequests

The subrequest must be created using an absolute path to keep the
informations about the host and the base path.
Closes #2168
Fabien Potencier 13 年之前
父節點
當前提交
2d4cb2e99c

+ 1 - 1
src/Symfony/Bundle/FrameworkBundle/HttpKernel.php

@@ -124,7 +124,7 @@ class HttpKernel extends BaseHttpKernel
 
         // controller or URI?
         if (0 === strpos($controller, '/')) {
-            $subRequest = Request::create($controller, 'get', array(), $request->cookies->all(), array(), $request->server->all());
+            $subRequest = Request::create($request->getUriForPath($controller), 'get', array(), $request->cookies->all(), array(), $request->server->all());
             $subRequest->setSession($request->getSession());
         } else {
             $options['attributes']['_controller'] = $controller;

+ 3 - 0
src/Symfony/Component/Security/Http/HttpUtils.php

@@ -71,6 +71,9 @@ class HttpUtils
             $this->resetLocale($request);
             $path = $this->generateUrl($path, true);
         }
+        if (0 !== strpos($path, 'http')) {
+            $path = $request->getUriForPath($path);
+        }
 
         $newRequest = Request::create($path, 'get', array(), $request->cookies->all(), array(), $request->server->all());
         if ($session = $request->getSession()) {