Skip to content
This repository was archived by the owner on May 31, 2024. It is now read-only.

Commit fa11a5f

Browse files
committed
feature #25836 [HttpKernel] Make session-related services extra-lazy (nicolas-grekas)
This PR was merged into the 4.1-dev branch. Discussion ---------- [HttpKernel] Make session-related services extra-lazy | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Commits ------- 5f535581b9 [HttpKernel] Make session-related services extra-lazy
2 parents fa51514 + db467df commit fa11a5f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Http/HttpUtils.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,13 @@ public function createRedirectResponse(Request $request, $path, $status = 302)
7777
public function createRequest(Request $request, $path)
7878
{
7979
$newRequest = Request::create($this->generateUri($request, $path), 'get', array(), $request->cookies->all(), array(), $request->server->all());
80-
if ($request->hasSession()) {
81-
$newRequest->setSession($request->getSession());
80+
81+
static $setSession;
82+
83+
if (null === $setSession) {
84+
$setSession = \Closure::bind(function ($newRequest, $request) { $newRequest->session = $request->session; }, null, Request::class);
8285
}
86+
$setSession($newRequest, $request);
8387

8488
if ($request->attributes->has(Security::AUTHENTICATION_ERROR)) {
8589
$newRequest->attributes->set(Security::AUTHENTICATION_ERROR, $request->attributes->get(Security::AUTHENTICATION_ERROR));

0 commit comments

Comments
 (0)