8000 Merge branch '5.4' into 6.0 · symfony/symfony@36dff8e · GitHub
[go: up one dir, main page]

Skip to content

Commit 36dff8e

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: clean up remaining event mocks fetch type information only once do not mock the Request class do not mock event classes Fix use_notify default value for PostgreSqlConnection recover from failed deserializations fix setDefaultCommand [ErrorHandle] Remove a link from the exception page [Validator] Added Ukrainian translations [DependencyInjection] Fix TaggedLocator attribute without index argument [GHA] Clarify some bits in the deps=high script [Cache] make `LockRegistry` use semaphores when possible [Security] Deprecate "always authenticate" and "exception on no token"
2 parents 30507bd + 64ff5b1 commit 36dff8e

40 files changed

+337
-371
lines changed

.github/workflows/unit-tests.yml

+7-5
Original file line numberDiff line numberDiff line change
@@ -183,24 +183,26 @@ jobs:
183183
# matrix.mode = high-deps
184184
echo "$COMPONENTS" | xargs -n1 | parallel -j +3 "_run_tests {} 'cd {} && $COMPOSER_UP && $PHPUNIT$LEGACY'" || X=1
185185
186+
# get a list of the patched components (relies on .github/build-packages.php being called in the previous step)
186187
(cd src/Symfony/Component/HttpFoundation; mv composer.bak composer.json)
187-
COMPONENTS=$(git diff --name-only src/ | grep composer.json || true)
188+
PATCHED_COMPONENTS=$(git diff --name-only src/ | grep composer.json || true)
188189
189-
if [[ $COMPONENTS && $SYMFONY_VERSION = *.4 ]]; then
190+
# for x.4 branches, checkout and test previous major with the patched components (only for patched components)
191+
if [[ $PATCHED_COMPONENTS && $SYMFONY_VERSION = *.4 ]]; then
190192
export FLIP='^'
191193
SYMFONY_VERSION=$(echo $SYMFONY_VERSION | awk '{print $1 - 1}')
192194
echo -e "\\n\\e[33;1mChecking out Symfony $SYMFONY_VERSION and running tests with patched components as deps\\e[0m"
193195
export COMPOSER_ROOT_VERSION=$SYMFONY_VERSION.x-dev
194196
export SYMFONY_REQUIRE=">=$SYMFONY_VERSION"
195197
git fetch --depth=2 origin $SYMFONY_VERSION
196198
git checkout -m FETCH_HEAD
197-
COMPONENTS=$(echo "$COMPONENTS" | xargs dirname | xargs -n1 -I{} bash -c "[ -e '{}/phpunit.xml.dist' ] && echo '{}'" | sort || true)
199+
PATCHED_COMPONENTS=$(echo "$PATCHED_COMPONENTS" | xargs dirname | xargs -n1 -I{} bash -c "[ -e '{}/phpunit.xml.dist' ] && echo '{}'" | sort || true)
198200
(cd src/Symfony/Component/HttpFoundation; composer require --dev --no-update mongodb/mongodb)
199-
if [[ $COMPONENTS ]]; then
201+
if [[ $PATCHED_COMPONENTS ]]; then
200202
echo "::group::install phpunit"
201203
./phpunit install
202204
echo "::endgroup::"
203-
echo "$COMPONENTS" | parallel -j +3 "_run_tests {} 'cd {} && rm composer.lock vendor/ -Rf && $COMPOSER_UP && $PHPUNIT$LEGACY'" || X=1
205+
echo "$PATCHED_COMPONENTS" | parallel -j +3 "_run_tests {} 'cd {} && rm composer.lock vendor/ -Rf && $COMPOSER_UP && $PHPUNIT$LEGACY'" || X=1
204206
fi
205207
fi
206208

UPGRADE-5.4.md

+14
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,17 @@ HttpKernel
1616
----------
1717

1818
* Deprecate `AbstractTestSessionListener::getSession` inject a session in the request instead
19+
20+
SecurityBundle
21+
--------------
22+
23+
* Deprecate the `always_authenticate_before_granting` option
24+
25+
Security
26+
--------
27+
28+
* Deprecate setting the 4th argument (`$alwaysAuthenticate`) to `true` and not setting the
29+
5th argument (`$exceptionOnNoToken`) to `false` of `AuthorizationChecker` (this is the default
30+
behavior when using `enable_authenticator_manager: true`)
31+
* Deprecate not setting the 5th argument (`$exceptionOnNoToken`) of `AccessListener` to `false`
32+
(this is the default behavior when using `enable_authenticator_manager: true`)

UPGRADE-6.0.md

+3
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ Routing
205205
Security
206206
--------
207207

208+
* Remove the 4th and 5th argument of `AuthorizationChecker`
209+
* Remove the 5th argument of `AccessListener`
208210
* Remove class `User`, use `InMemoryUser` or your own implementation instead.
209211
If you are using the `isAccountNonLocked()`, `isAccountNonExpired()` or `isCredentialsNonExpired()` method, consider re-implementing them
210212
in your own user class as they are not part of the `InMemoryUser` API
@@ -324,6 +326,7 @@ Security
324326
SecurityBundle
325327
--------------
326328

329+
* Remove the `always_authenticate_before_granting` option
327330
* Remove the `UserPasswordEncoderCommand` class and the corresponding `user:encode-password` command,
328331
use `UserPasswordHashCommand` and `user:hash-password` instead
329332
* Remove the `security.encoder_factory.generic` service, the `security.encoder_factory` and `Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface` aliases,

src/Symfony/Bridge/Monolog/Tests/Processor/ConsoleCommandProcessorTest.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\Console\Command\Command;
1717
use Symfony\Component\Console\Event\ConsoleEvent;
1818
use Symfony\Component\Console\Input\InputInterface;
19+
use Symfony\Component\Console\Output\OutputInterface;
1920

2021
class ConsoleCommandProcessorTest extends TestCase
2122
{
@@ -66,10 +67,7 @@ private function getConsoleEvent(): ConsoleEvent
6667
$input->method('getOptions')->willReturn(self::TEST_OPTIONS);
6768
$command = $this->createMock(Command::class);
6869
$command->method('getName')->willReturn(self::TEST_NAME);
69-
$consoleEvent = $this->createMock(ConsoleEvent::class);
70-
$consoleEvent->method('getCommand')->willReturn($command);
71-
$consoleEvent->method('getInput')->willReturn($input);
7270

73-
return $consoleEvent;
71+
return new ConsoleEvent($command, $input, $this->createMock(OutputInterface::class));
7472
}
7573
}

src/Symfony/Bundle/SecurityBundle/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ CHANGELOG
1212
* Remove the `security.user_password_encoder.generic` service, the `security.password_encoder` and the `Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface` aliases,
1313
use `security.user_password_hasher`, `security.password_hasher` and `Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface` instead
1414

15+
5.4
16+
---
17+
18+
* Deprecate the `always_authenticate_before_granting` option
19+
20+
1521
5.3
1622
---
1723

src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ public function getConfigTreeBuilder()
7373
->defaultValue(SessionAuthenticationStrategy::MIGRATE)
7474
->end()
7575
->booleanNode('hide_user_not_found')->defaultTrue()->end()
76-
->booleanNode('always_authenticate_before_granting')->defaultFalse()->end()
76+
->booleanNode('always_authenticate_before_granting')
77+
->defaultFalse()
78+
->setDeprecated('symfony/security-bundle', '5.4')
79+
->end()
7780
->booleanNode('erase_credentials')->defaultTrue()->end()
7881
->booleanNode('enable_authenticator_manager')->defaultFalse()->info('Enables the new Symfony Security system based on Authenticators, all used authenticators must support this before enabling this.')->end()
7982
->arrayNode('access_decision_manager')

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php

+3
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,9 @@ public function provideEntryPointRequiredData()
635635
];
636636
}
637637

638+
/**
639+
* @group legacy
640+
*/
638641
public function testAlwaysAuthenticateBeforeGrantingCannotBeTrueWithAuthenticatorManager()
639642
{
640643
$this->expectException(InvalidConfigurationException::class);

src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php

+23-45
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Bundle\WebProfilerBundle\Csp\ContentSecurityPolicyHandler;
1616
use Symfony\Bundle\WebProfilerBundle\EventListener\WebDebugToolbarListener;
17-
use Symfony\Component\HttpFoundation\HeaderBag;
1817
use Symfony\Component\HttpFoundation\Request;
1918
use Symfony\Component\HttpFoundation\Response;
2019
use Symfony\Component\HttpFoundation\Session\Session;
@@ -63,11 +62,11 @@ public function getInjectToolbarTests()
6362
/**
6463
* @dataProvider provideRedirects
6564
*/
66-
public function testHtmlRedirectionIsIntercepted($statusCode, $hasSession)
65+
public function testHtmlRedirectionIsIntercepted($statusCode)
6766
{
6867
$response = new Response('Some content', $statusCode);
6968
$response->headers->set('X-Debug-Token', 'xxxxxxxx');
70-
$event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(false, 'html', $hasSession), HttpKernelInterface::MAIN_REQUEST, $response);
69+
$event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MAIN_REQUEST, $response);
7170

7271
$listener = new WebDebugToolbarListener($this->getTwigMock('Redirection'), true);
7372
$listener->onKernelResponse($event);
@@ -80,7 +79,7 @@ public function testNonHtmlRedirectionIsNotIntercepted()
8079
{
8180
$response = new Response('Some content', '301');
8281
$response->headers->set('X-Debug-Token', 'xxxxxxxx');
83-
$event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(false, 'json', true), HttpKernelInterface::MAIN_REQUEST, $response);
82+
$event = new ResponseEvent($this->createMock(Kernel::class), new Request([], [], ['_format' => 'json']), HttpKernelInterface::MAIN_REQUEST, $response);
8483

8584
$listener = new WebDebugToolbarListener($this->getTwigMock('Redirection'), true);
8685
$listener->onKernelResponse($event);
@@ -94,7 +93,7 @@ public function testToolbarIsInjected()
9493
$response = new Response('<html><head></head><body></body></html>');
9594
$response->headers->set('X-Debug-Token', 'xxxxxxxx');
9695

97-
$event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MAIN_REQUEST, $response);
96+
$event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MAIN_REQUEST, $response);
9897

9998
$listener = new WebDebugToolbarListener($this->getTwigMock());
10099
$listener->onKernelResponse($event);
@@ -110,7 +109,7 @@ public function testToolbarIsNotInjectedOnNonHtmlContentType()
110109
$response = new Response('<html><head></head><body></body></html>');
111110
$response->headers->set('X-Debug-Token', 'xxxxxxxx');
112111
$response->headers->set('Content-Type', 'text/xml');
113-
$event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MAIN_REQUEST, $response);
112+
$event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MAIN_REQUEST, $response);
114113

115114
$listener = new WebDebugToolbarListener($this->getTwigMock());
116115
$listener->onKernelResponse($event);
@@ -126,7 +125,7 @@ public function testToolbarIsNotInjectedOnContentDispositionAttachment()
126125
$response = new Response('<html><head></head><body></body></html>');
127126
$response->headers->set('X-Debug-Token', 'xxxxxxxx');
128127
$response->headers->set('Content-Disposition', 'attachment; filename=test.html');
129-
$event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(false, 'html'), HttpKernelInterface::MAIN_REQUEST, $response);
128+
$event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MAIN_REQUEST, $response);
130129

131130
$listener = new WebDebugToolbarListener($this->getTwigMock());
132131
$listener->onKernelResponse($event);
@@ -138,11 +137,11 @@ public function testToolbarIsNotInjectedOnContentDispositionAttachment()
138137
* @depends testToolbarIsInjected
139138
* @dataProvider provideRedirects
140139
*/
141-
public function testToolbarIsNotInjectedOnRedirection($statusCode, $hasSession)
140+
public function testToolbarIsNotInjectedOnRedirection($statusCode)
142141
{
143142
$response = new Response('<html><head></head><body></body></html>', $statusCode);
144143
$response->headers->set('X-Debug-Token', 'xxxxxxxx');
145-
$event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(false, 'html', $hasSession), HttpKernelInterface::MAIN_REQUEST, $response);
144+
$event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MAIN_REQUEST, $response);
146145

147146
$listener = new WebDebugToolbarListener($this->getTwigMock());
148147
$listener->onKernelResponse($event);
@@ -153,10 +152,8 @@ public function testToolbarIsNotInjectedOnRedirection($statusCode, $hasSession)
153152
public function provideRedirects()
154153
{
155154
return [
156-
[301, true],
157-
[302, true],
158-
[301, false],
159-
[302, false],
155+
[301],
156+
[302],
160157
];
161158
}
162159

@@ -167,7 +164,7 @@ public function testToolbarIsNotInjectedWhenThereIsNoNoXDebugTokenResponseHeader
167164
{
168165
$response = new Response('<html><head></head><body></body></html>');
169166

170-
$event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MAIN_REQUEST, $response);
167+
$event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MAIN_REQUEST, $response);
171168

172169
$listener = new WebDebugToolbarListener($this->getTwigMock());
173170
$listener->onKernelResponse($event);
@@ -183,7 +180,7 @@ public function testToolbarIsNotInjectedWhenOnSubRequest()
183180
$response = new Response('<html><head></head><body></body></html>');
184181
$response->headers->set('X-Debug-Token', 'xxxxxxxx');
185182

186-
$event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::SUB_REQUEST, $response);
183+
$event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::SUB_REQUEST, $response);
187184

188185
$listener = new WebDebugToolbarListener($this->getTwigMock());
189186
$listener->onKernelResponse($event);
@@ -199,7 +196,7 @@ public function testToolbarIsNotInjectedOnIncompleteHtmlResponses()
199196
$response = new Response('<div>Some content</div>');
200197
$response->headers->set('X-Debug-Token', 'xxxxxxxx');
201198

202-
$event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MAIN_REQUEST, $response);
199+
$event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MAIN_REQUEST, $response);
203200

204201
$listener = new WebDebugToolbarListener($this->getTwigMock());
205202
$listener->onKernelResponse($event);
@@ -215,7 +212,10 @@ public function testToolbarIsNotInjectedOnXmlHttpRequests()
215212
$response = new Response('<html><head></head><body></body></html>');
216213
$response->headers->set('X-Debug-Token', 'xxxxxxxx');
217214

218-
$event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(true), HttpKernelInterface::MAIN_REQUEST, $response);
215+
$request = new Request();
216+
$request->headers->set('X-Requested-With', 'XMLHttpRequest');
217+
218+
$event = new ResponseEvent($this->createMock(Kernel::class), $request, HttpKernelInterface::MAIN_REQUEST, $response);
219219

220220
$listener = new WebDebugToolbarListener($this->getTwigMock());
221221
$listener->onKernelResponse($event);
@@ -231,7 +231,7 @@ public function testToolbarIsNotInjectedOnNonHtmlRequests()
231231
$response = new Response('<html><head></head><body></body></html>');
232232
$response->headers->set('X-Debug-Token', 'xxxxxxxx');
233233

234-
$event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(false, 'json'), HttpKernelInterface::MAIN_REQUEST, $response);
234+
$event = new ResponseEvent($this->createMock(Kernel::class), new Request([], [], ['_format' => 'json']), HttpKernelInterface::MAIN_REQUEST, $response);
235235

236236
$listener = new WebDebugToolbarListener($this->getTwigMock());
237237
$listener->onKernelResponse($event);
@@ -252,7 +252,7 @@ public function testXDebugUrlHeader()
252252
->willReturn('http://mydomain.com/_profiler/xxxxxxxx')
253253
;
254254

255-
$event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MAIN_REQUEST, $response);
255+
$event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MAIN_REQUEST, $response);
256256

257257
$listener = new WebDebugToolbarListener($this->getTwigMock(), false, WebDebugToolbarListener::ENABLED, $urlGenerator);
258258
$listener->onKernelResponse($event);
@@ -273,7 +273,7 @@ public function testThrowingUrlGenerator()
273273
->willThrowException(new \Exception('foo'))
274274
;
275275

276-
$event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MAIN_REQUEST, $response);
276+
$event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MAIN_REQUEST, $response);
277277

278278
$listener = new WebDebugToolbarListener($this->getTwigMock(), false, WebDebugToolbarListener::ENABLED, $urlGenerator);
279279
$listener->onKernelResponse($event);
@@ -294,7 +294,7 @@ public function testThrowingErrorCleanup()
294294
->willThrowException(new \Exception("This\nmultiline\r\ntabbed text should\tcome out\r on\n \ta single plain\r\nline"))
295295
;
296296

297-
$event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MAIN_REQUEST, $response);
297+
$event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MAIN_REQUEST, $response);
298298

299299
$listener = new WebDebugToolbarListener($this->getTwigMock(), false, WebDebugToolbarListener::ENABLED, $urlGenerator);
300300
$listener->onKernelResponse($event);
@@ -307,7 +307,7 @@ public function testCspIsDisabledIfDumperWasUsed()
307307
$response = new Response('<html><head></head><body></body></html>');
308308
$response->headers->set('X-Debug-Token', 'xxxxxxxx');
309309

310-
$event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MAIN_REQUEST, $response);
310+
$event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MAIN_REQUEST, $response);
311311

312312
$cspHandler = $this->createMock(ContentSecurityPolicyHandler::class);
313313
$cspHandler->expects($this->once())
@@ -328,7 +328,7 @@ public function testCspIsKeptEnabledIfDumperWasNotUsed()
328328
$response = new Response('<html><head></head><body></body></html>');
329329
$response->headers->set('X-Debug-Token', 'xxxxxxxx');
330330

331-
$event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MAIN_REQUEST, $response);
331+
$event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MAIN_REQUEST, $response);
332332

333333
$cspHandler = $this->createMock(ContentSecurityPolicyHandler::class);
334334
$cspHandler->expects($this->never())
@@ -344,28 +344,6 @@ public function testCspIsKeptEnabledIfDumperWasNotUsed()
344344
$this->assertEquals("<html><head></head><body>\nWDT\n</body></html>", $response->getContent());
345345
}
346346

347-
protected function getRequestMock($isXmlHttpRequest = false, $requestFormat = 'html', $hasSession = true)
348-
{
349-
$request = $this->getMockBuilder(Request::class)->setMethods(['getSession', 'isXmlHttpRequest', 'getRequestFormat'])->disableOriginalConstructor()->getMock();
350-
$request->expects($this->any())
351-
->method('isXmlHttpRequest')
352-
->willReturn($isXmlHttpRequest);
353-
$request->expects($this->any())
354-
->method('getRequestFormat')
355-
->willReturn($requestFormat);
356-
357-
$request->headers = new HeaderBag();
358-
359-
if ($hasSession) {
360-
$session = $this->createMock(Session::class);
361-
$request->expects($this->any())
362-
->method('getSession')
363-
->willReturn($session);
364-
}
365-
366-
return $request;
367-
}
368-
369347
protected function getTwigMock($render = 'WDT')
370348
{
371349
$templating = $this->createMock(Environment::class);

src/Symfony/Component/Cache/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ CHANGELOG
99
5.4
1010
---
1111

12+
* Make `LockRegistry` use semaphores when possible
1213
* Deprecate `DoctrineProvider` because this class has been added to the `doctrine/cache` package
1314

1415
5.3

0 commit comments

Comments
 (0)
0