Skip to content

Commit

Permalink
revert "Symfony標準のセッションハンドラを利用する"
Browse files Browse the repository at this point in the history
  • Loading branch information
chihiro-adachi committed Jan 17, 2024
1 parent 683bd89 commit e09e438
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 22 deletions.
5 changes: 1 addition & 4 deletions app/config/eccube/packages/framework.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@ framework:
trusted_hosts: ~
# https://symfony.com/doc/current/reference/configuration/framework.html#handler-id
session:
handler_id: session.handler.native_file
handler_id: 'Eccube\Session\Storage\Handler\SameSiteNoneCompatSessionHandler'
save_path: '%kernel.project_dir%/var/sessions/%kernel.environment%'
name: '%env(ECCUBE_COOKIE_NAME)%'
cookie_path: '%env(ECCUBE_COOKIE_PATH)%'
cookie_lifetime: '%env(ECCUBE_COOKIE_LIFETIME)%'
gc_maxlifetime: '%env(ECCUBE_GC_MAXLIFETIME)%'
cookie_httponly: true
cookie_samesite: none
cookie_secure: true

# When using the HTTP Cache, ESI allows to render page fragments separately
# and with different cache configurations for each fragment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class SameSiteNoneCompatSessionHandler extends StrictSessionHandler
*/
public function __construct(\SessionHandlerInterface $handler)
{
parent::__construct($handler);

$this->handler = $handler;

ini_set('session.cookie_secure', $this->getCookieSecure());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ public static function tearDownAfterClass(): void
}
}

public function setUp(): void
{
self::markTestIncomplete('デフォルトのセッションハンドラで4.2と互換性が担保できるか確認');
parent::setUp();
}

/**
* @dataProvider provideSession
*/
Expand Down
27 changes: 15 additions & 12 deletions tests/Fixtures/session/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@
(Dotenv::createUnsafeMutable($parent, '.env'))->load();
}

Request::setTrustedProxies(['127.0.0.1', '::1', 'REMOTE_ADDR'], Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
Request::setTrustedProxies(
['127.0.0.1', '::1', 'REMOTE_ADDR'],
Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_HOST | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO ^ Request::HEADER_X_FORWARDED_HOST
);
Request::setTrustedHosts(['127.0.0.1', '::1']);
Request::createFromGlobals();

Expand Down Expand Up @@ -106,7 +109,7 @@ public function __construct(SessionHandlerInterface $handler)
}

#[\ReturnTypeWillChange]
public function open($path, $name)
public function open($path, $name): bool
{
echo __FUNCTION__, "\n";

Expand All @@ -117,7 +120,7 @@ public function open($path, $name)
* {@inheritdoc}
*/
#[\ReturnTypeWillChange]
public function validateId($sessionId)
public function validateId($sessionId): bool
{
echo __FUNCTION__, "\n";

Expand All @@ -128,7 +131,7 @@ public function validateId($sessionId)
* {@inheritdoc}
*/
#[\ReturnTypeWillChange]
public function read($sessionId)
public function read($sessionId): string
{
echo __FUNCTION__, "\n";

Expand All @@ -139,7 +142,7 @@ public function read($sessionId)
* {@inheritdoc}
*/
#[\ReturnTypeWillChange]
public function updateTimestamp($sessionId, $data)
public function updateTimestamp($sessionId, $data): bool
{
echo __FUNCTION__, "\n";

Expand All @@ -150,7 +153,7 @@ public function updateTimestamp($sessionId, $data)
* {@inheritdoc}
*/
#[\ReturnTypeWillChange]
public function write($sessionId, $data)
public function write($sessionId, $data): bool
{
echo __FUNCTION__, "\n";

Expand All @@ -161,7 +164,7 @@ public function write($sessionId, $data)
* {@inheritdoc}
*/
#[\ReturnTypeWillChange]
public function destroy($sessionId)
public function destroy($sessionId):bool
{
echo __FUNCTION__, "\n";

Expand All @@ -172,7 +175,7 @@ public function destroy($sessionId)
* {@inheritdoc}
*/
#[\ReturnTypeWillChange]
public function close()
public function close(): bool
{
echo __FUNCTION__, "\n";

Expand All @@ -183,14 +186,14 @@ public function close()
* {@inheritdoc}
*/
#[\ReturnTypeWillChange]
public function gc($maxLifetime)
public function gc($maxLifetime): int|false
{
echo __FUNCTION__, "\n";

return true;
}

protected function doRead($sessionId)
protected function doRead($sessionId): string
{
if (isset($this->sessionId) && $sessionId !== $this->sessionId) {
echo __FUNCTION__ . ": invalid sessionId\n";
Expand All @@ -203,15 +206,15 @@ protected function doRead($sessionId)
return $this->data;
}

protected function doWrite($sessionId, $data)
protected function doWrite($sessionId, $data): bool
{
echo __FUNCTION__.': ', $data, "\n";
$this->sessionId = $sessionId;

return true;
}

protected function doDestroy($sessionId)
protected function doDestroy($sessionId): bool
{
echo __FUNCTION__, "\n";
$this->sessionId = $sessionId;
Expand Down

0 comments on commit e09e438

Please sign in to comment.