8000 [HttpFoundation] Fix invalid ID not regenerated with native PHP file sessions by Rezyan · Pull Request #47130 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[HttpFoundation] Fix invalid ID not regenerated with native PHP file sessions #47130

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 1 commit into from
Aug 1, 2022
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 @@ -30,6 +30,16 @@ public function __construct(\SessionHandlerInterface $handler)
$this->handler = $handler;
}

/**
* Returns true if this handler wraps an internal PHP session save handler using \SessionHandler.
*
* @internal
*/
public function isWrapper(): bool
{
return $this->handler instanceof \SessionHandler;
}

/**
* @return bool
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

namespace Symfony\Component\HttpFoundation\Session\Storage\Proxy;

use Symfony\Component\HttpFoundation\Session\Storage\Handler\StrictSessionHandler;

/**
* @author Drak <drak@zikula.org>
*/
Expand All @@ -22,7 +24,7 @@ public function __construct(\SessionHandlerInterface $handler)
{
$this->handler = $handler;
$this->wrapper = $handler instanceof \SessionHandler;
$this->saveHandlerName = $this->wrapper ? \ini_get('session.save_handler') : 'user';
$this->saveHandlerName = $this->wrapper || ($handler instanceof StrictSessionHandler && $handler->isWrapper()) ? \ini_get('session.save_handler') : 'user';
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Proxy;

use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Session\Storage\Handler\StrictSessionHandler;
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
use Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy;

/**
Expand Down Expand Up @@ -159,6 +161,23 @@ public function testUpdateTimestamp()

$this->proxy->updateTimestamp('id', 'data');
}

/**
* @dataProvider provideNativeSessionStorageHandler
*/
public function testNativeSessionStorageSaveHandlerName($handler)
{
$this->assertSame('files', (new NativeSessionStorage([], $handler))->getSaveHandler()->getSaveHandlerName());
}

public function provideNativeSessionStorageHandler()
{
return [
[new \SessionHandler()],
[new StrictSessionHandler(new \SessionHandler())],
[new SessionHandlerProxy(new StrictSessionHandler(new \SessionHandler()))],
];
}
}

abstract class TestSessionHandler implements \SessionHandlerInterface, \SessionUpdateTimestampHandlerInterface
Expand Down
0