Skip to content

Commit 094f340

Browse files
Merge branch '5.4' into 6.0
* 5.4: (21 commits) Add missing license header [Workflow] Catch error when trying to get an uninitialized marking Add missing license header Allow usage of Provider domains if possible Use reference date in reverse transform Fixes #40997 Fix env resolution in lock configuration Fix Symfony not working on SMB share #45990 [Messenger] DoctrineTransportFactory works with notify and decorated PostgreSQL driver [Cache] make LockRegistry use static properties instead of static variables fix: return-path has higher priority for envelope address than from address (fixes #41322) [HttpClient] Fix sending content-length when streaming the body [Console] Header with column max width is now well wrap with separator Fix use_cookies framework session configuration [FrameworkBundle] [Command] Fix `debug:router --no-interaction` error … [Intl] Update the ICU data to 71.1 - 5.4 [Intl] Update the ICU data to 71.1 - 4.4 Add tests to messenger connection get for OraclePlatform [RateLimiter] Adding default empty value [DependencyInjection] Add TaggedIteratorArgument unit tests [Process] Fix Process::getEnv() when setEnv() hasn't been called before ...
2 parents 22d68ff + 11ce6c6 commit 094f340

22 files changed

+220
-36
lines changed

EventListener/AbstractSessionListener.php

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -143,42 +143,45 @@ public function onKernelResponse(ResponseEvent $event)
143143
$sessionCookieSecure = $sessionOptions['cookie_secure'] ?? false;
144144
$sessionCookieHttpOnly = $sessionOptions['cookie_httponly'] ?? true;
145145
$sessionCookieSameSite = $sessionOptions['cookie_samesite'] ?? Cookie::SAMESITE_LAX;
146+
$sessionUseCookies = $sessionOptions['use_cookies'] ?? true;
146147

147148
SessionUtils::popSessionCookie($sessionName, $sessionId);
148149

149-
$request = $event->getRequest();
150-
$requestSessionCookieId = $request->cookies->get($sessionName);
151-
152-
$isSessionEmpty = ($session instanceof Session ? $session->isEmpty() : empty($session->all())) && empty($_SESSION); // checking $_SESSION to keep compatibility with native sessions
153-
if ($requestSessionCookieId && $isSessionEmpty) {
154-
$response->headers->clearCookie(
155-
$sessionName,
156-
$sessionCookiePath,
157-
$sessionCookieDomain,
158-
$sessionCookieSecure,
159-
$sessionCookieHttpOnly,
160-
$sessionCookieSameSite
161-
);
162-
} elseif ($sessionId !== $requestSessionCookieId && !$isSessionEmpty) {
163-
$expire = 0;
164-
$lifetime = $sessionOptions['cookie_lifetime'] ?? null;
165-
if ($lifetime) {
166-
$expire = time() + $lifetime;
167-
}
150+
if ($sessionUseCookies) {
151+
$request = $event->getRequest();
152+
$requestSessionCookieId = $request->cookies->get($sessionName);
168153

169-
$response->headers->setCookie(
170-
Cookie::create(
154+
$isSessionEmpty = ($session instanceof Session ? $session->isEmpty() : empty($session->all())) && empty($_SESSION); // checking $_SESSION to keep compatibility with native sessions
155+
if ($requestSessionCookieId && $isSessionEmpty) {
156+
$response->headers->clearCookie(
171157
$sessionName,
172-
$sessionId,
173-
$expire,
174158
$sessionCookiePath,
175159
$sessionCookieDomain,
176160
$sessionCookieSecure,
177161
$sessionCookieHttpOnly,
178-
false,
179162
$sessionCookieSameSite
180-
)
181-
);
163+
);
164+
} elseif ($sessionId !== $requestSessionCookieId && !$isSessionEmpty) {
165+
$expire = 0;
166+
$lifetime = $sessionOptions['cookie_lifetime'] ?? null;
167+
if ($lifetime) {
168+
$expire = time() + $lifetime;
169+
}
170+
171+
$response->headers->setCookie(
172+
Cookie::create(
173+
$sessionName,
174+
$sessionId,
175+
$expire,
176+
$sessionCookiePath,
177+
$sessionCookieDomain,
178+
$sessionCookieSecure,
179+
$sessionCookieHttpOnly,
180+
false,
181+
$sessionCookieSameSite
182+
)
183+
);
184+
}
182185
}
183186
}
184187

Kernel.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,9 +460,7 @@ protected function initializeContainer()
460460
is_dir($buildDir) ?: mkdir($buildDir, 0777, true);
461461

462462
if ($lock = fopen($cachePath.'.lock', 'w')) {
463-
flock($lock, \LOCK_EX | \LOCK_NB, $wouldBlock);
464-
465-
if (!flock($lock, $wouldBlock ? \LOCK_SH : \LOCK_EX)) {
463+
if (!flock($lock, \LOCK_EX | \LOCK_NB, $wouldBlock) && !flock($lock, $wouldBlock ? \LOCK_SH : \LOCK_EX)) {
466464
fclose($lock);
467465
$lock = null;
468466
} elseif (!is_file($cachePath) || !\is_object($this->container = include $cachePath)) {

Tests/DependencyInjection/RegisterLocaleAwareServicesPassTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Symfony\Component\HttpKernel\Tests\DependencyInjection;
413

514
use PHPUnit\Framework\TestCase;

Tests/DependencyInjection/ResettableServicePassTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Symfony\Component\HttpKernel\Tests\DependencyInjection;
413

514
use PHPUnit\Framework\TestCase;

Tests/Event/ControllerArgumentsEventTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Symfony\Component\HttpKernel\Tests\Event;
413

514
use PHPUnit\Framework\TestCase;

Tests/EventListener/SessionListenerTest.php

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,19 @@ public function testSessionCookieOptions(array $phpSessionOptions, array $sessio
6565
$listener->onKernelResponse(new ResponseEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST, $response));
6666

6767
$cookies = $response->headers->getCookies();
68-
$this->assertSame('PHPSESSID', $cookies[0]->getName());
69-
$this->assertSame('123456', $cookies[0]->getValue());
70-
$this->assertSame($expectedSessionOptions['cookie_path'], $cookies[0]->getPath());
71-
$this->assertSame($expectedSessionOptions['cookie_domain'], $cookies[0]->getDomain());
72-
$this->assertSame($expectedSessionOptions['cookie_secure'], $cookies[0]->isSecure());
73-
$this->assertSame($expectedSessionOptions['cookie_httponly'], $cookies[0]->isHttpOnly());
74-
$this->assertSame($expectedSessionOptions['cookie_samesite'], $cookies[0]->getSameSite());
68+
69+
if ($sessionOptions['use_cookies'] ?? true) {
70+
$this->assertCount(1, $cookies);
71+
$this->assertSame('PHPSESSID', $cookies[0]->getName());
72+
$this->assertSame('123456', $cookies[0]->getValue());
73+
$this->assertSame($expectedSessionOptions['cookie_path'], $cookies[0]->getPath());
74+
$this->assertSame($expectedSessionOptions['cookie_domain'], $cookies[0]->getDomain());
75+
$this->assertSame($expectedSessionOptions['cookie_secure'], $cookies[0]->isSecure());
76+
$this->assertSame($expectedSessionOptions['cookie_httponly'], $cookies[0]->isHttpOnly());
77+
$this->assertSame($expectedSessionOptions['cookie_samesite'], $cookies[0]->getSameSite());
78+
} else {
79+
$this->assertCount(0, $cookies);
80+
}
7581
}
7682

7783
public function provideSessionOptions(): \Generator
@@ -125,6 +131,12 @@ public function provideSessionOptions(): \Generator
125131
'sessionOptions' => ['cookie_path' => '/test/', 'cookie_httponly' => true, 'cookie_secure' => true, 'cookie_samesite' => Cookie::SAMESITE_LAX],
126132
'expectedSessionOptions' => ['cookie_path' => '/test/', 'cookie_domain' => '', 'cookie_secure' => true, 'cookie_httponly' => true, 'cookie_samesite' => Cookie::SAMESITE_LAX],
127133
];
134+
135+
yield 'set_use_cookies_false_by_symfony' => [
136+
'phpSessionOptions' => [],
137+
'sessionOptions' => ['use_cookies' => false, 'cookie_domain' => '', 'cookie_secure' => true, 'cookie_httponly' => true, 'cookie_samesite' => Cookie::SAMESITE_LAX],
138+
'expectedSessionOptions' => [],
139+
];
128140
}
129141

130142
/**

Tests/Exception/AccessDeniedHttpExceptionTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Symfony\Component\HttpKernel\Tests\Exception;
413

514
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;

Tests/Exception/BadRequestHttpExceptionTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Symfony\Component\HttpKernel\Tests\Exception;
413

514
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;

Tests/Exception/ConflictHttpExceptionTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Symfony\Component\HttpKernel\Tests\Exception;
413

514
use Symfony\Component\HttpKernel\Exception\ConflictHttpException;

Tests/Exception/GoneHttpExceptionTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Symfony\Component\HttpKernel\Tests\Exception;
413

514
use Symfony\Component\HttpKernel\Exception\GoneHttpException;

Tests/Exception/HttpExceptionTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Symfony\Component\HttpKernel\Tests\Exception;
413

514
use PHPUnit\Framework\TestCase;

Tests/Exception/LengthRequiredHttpExceptionTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Symfony\Component\HttpKernel\Tests\Exception;
413

514
use Symfony\Component\HttpKernel\Exception\HttpException;

Tests/Exception/MethodNotAllowedHttpExceptionTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Symfony\Component\HttpKernel\Tests\Exception;
413

514
use Symfony\Component\HttpKernel\Exception\HttpException;

Tests/Exception/NotAcceptableHttpExceptionTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Symfony\Component\HttpKernel\Tests\Exception;
413

514
use Symfony\Component\HttpKernel\Exception\HttpException;

Tests/Exception/NotFoundHttpExceptionTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Symfony\Component\HttpKernel\Tests\Exception;
413

514
use Symfony\Component\HttpKernel\Exception\HttpException;

Tests/Exception/PreconditionFailedHttpExceptionTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Symfony\Component\HttpKernel\Tests\Exception;
413

514
use Symfony\Component\HttpKernel\Exception\HttpException;

Tests/Exception/PreconditionRequiredHttpExceptionTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Symfony\Component\HttpKernel\Tests\Exception;
413

514
use Symfony\Component\HttpKernel\Exception\HttpException;

Tests/Exception/ServiceUnavailableHttpExceptionTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Symfony\Component\HttpKernel\Tests\Exception;
413

514
use Symfony\Component\HttpKernel\Exception\HttpException;

Tests/Exception/TooManyRequestsHttpExceptionTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Symfony\Component\HttpKernel\Tests\Exception;
413

514
use Symfony\Component\HttpKernel\Exception\HttpException;

Tests/Exception/UnauthorizedHttpExceptionTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Symfony\Component\HttpKernel\Tests\Exception;
413

514
use Symfony\Component\HttpKernel\Exception\HttpException;

Tests/Exception/UnprocessableEntityHttpExceptionTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Symfony\Component\HttpKernel\Tests\Exception;
413

514
use Symfony\Component\HttpKernel\Exception\HttpException;

0 commit comments

Comments
 (0)