Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[HttpFoundation] fix session tracking counter #27714

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ public function welcomeAction(Request $request, $name = null)
return new Response(sprintf('Welcome back %s, nice to meet you.', $name));
}

public function cacheableAction()
{
$response = new Response('all good');
$response->setSharedMaxAge(100);

return $response;
}

public function logoutAction(Request $request)
{
$request->getSession()->invalidate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ session_welcome:
path: /session
defaults: { _controller: TestBundle:Session:welcome }

session_cacheable:
path: /cacheable
defaults: { _controller: Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller\SessionController::cacheableAction }

session_welcome_name:
path: /session/{name}
defaults: { _controller: TestBundle:Session:welcome }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,22 @@ public function testTwoClients($config, $insulate)
$this->assertContains('Welcome back client2, nice to meet you.', $crawler2->text());
}

/**
* @dataProvider getConfigs
*/
public function testCorrectCacheControlHeadersForCacheableAction($config, $insulate)
{
$client = $this->createClient(array('test_case' => 'Session', 'root_config' => $config));
if ($insulate) {
$client->insulate();
}

$client->request('GET', '/cacheable');

$response = $client->getResponse();
$this->assertSame('public, s-maxage=100', $response->headers->get('cache-control'));
}

public function getConfigs()
{
return array(
Expand Down
10 changes: 3 additions & 7 deletions 10 src/Symfony/Component/HttpFoundation/Session/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ public function __construct(SessionStorageInterface $storage = null, AttributeBa
*/
public function start()
{
++$this->usageIndex;

return $this->storage->start();
}

Expand Down Expand Up @@ -160,7 +158,9 @@ public function getUsageIndex()
*/
public function isEmpty()
{
++$this->usageIndex;
if ($this->isStarted()) {
++$this->usageIndex;
}
foreach ($this->data as &$data) {
if (!empty($data)) {
return false;
Expand All @@ -185,8 +185,6 @@ public function invalidate($lifetime = null)
*/
public function migrate($destroy = false, $lifetime = null)
{
++$this->usageIndex;

return $this->storage->regenerate($destroy, $lifetime);
}

Expand All @@ -195,8 +193,6 @@ public function migrate($destroy = false, $lifetime = null)
*/
public function save()
{
++$this->usageIndex;

$this->storage->save();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public function getBag()
*/
public function isEmpty()
{
if (!isset($this->data[$this->bag->getStorageKey()])) {
return true;
}
++$this->usageIndex;

return empty($this->data[$this->bag->getStorageKey()]);
Expand Down Expand Up @@ -81,8 +84,6 @@ public function getStorageKey()
*/
public function clear()
{
++$this->usageIndex;

return $this->bag->clear();
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.