8000 Merge branch '4.4' into 5.0 · symfony/symfony@15f7ea1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 15f7ea1

Browse files
Merge branch '4.4' into 5.0
* 4.4: [HttpKernel] Make ErrorListener::onKernelException()'s dispatcher argument explicit Removed extra whitespace [Security] Fix best encoder not wired using migrate_from
2 parents 73300a6 + 4498e7e commit 15f7ea1

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

src/Symfony/Component/ErrorHandler/ErrorRenderer/HtmlErrorRenderer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function __construct(bool $debug = false, string $charset = null, $fileLi
5252
/**
5353
* {@inheritdoc}
5454
*/
55-
public function render(\Throwable $exception): FlattenException
55+
public function render(\Throwable $exception): FlattenException
5656
{
5757
$exception = FlattenException::createFromThrowable($exception, null, [
5858
'Content-Type' => 'text/html; charset='.$this->charset,

src/Symfony/Component/HttpKernel/EventListener/ErrorListener.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,14 @@ public function logKernelException(ExceptionEvent $event)
4646
$this->logException($event->getThrowable(), sprintf('Uncaught PHP Exception %s: "%s" at %s line %s', $e->getClass(), $e->getMessage(), $e->getFile(), $e->getLine()));
4747
}
4848

49-
public function onKernelException(ExceptionEvent $event)
49+
public function onKernelException(ExceptionEvent $event, string $eventName = null, EventDispatcherInterface $eventDispatcher = null)
5050
{
5151
if (null === $this->controller) {
5252
return;
5353
}
5454

5555
$exception = $event->getThrowable();
5656
$request = $this->duplicateRequest($exception, $event->getRequest());
57-
$eventDispatcher = \func_num_args() > 2 ? func_get_arg(2) : null;
5857

5958
try {
6059
$response = $event->getKernel()->handle($request, HttpKernelInterface::SUB_REQUEST, false);

src/Symfony/Component/Security/Core/Encoder/EncoderFactory.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ private function getEncoderConfigFromAlgorithm(array $config): array
114114
}
115115

116116
if ($fromEncoders = ($config['migrate_from'] ?? false)) {
117-
$encoderChain = [];
117+
unset($config['migrate_from']);
118+
$encoderChain = [$this->createEncoder($config, true)];
119+
118120
foreach ($fromEncoders as $name) {
119121
if ($encoder = $this->encoders[$name] ?? false) {
120122
$encoder = $encoder instanceof PasswordEncoderInterface ? $encoder : $this->createEncoder($encoder, true);

src/Symfony/Component/Security/Core/Tests/Encoder/EncoderFactoryTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,7 @@ public function testMigrateFrom()
143143

144144
$factory = new EncoderFactory([
145145
'digest_encoder' => $digest = new MessageDigestPasswordEncoder('sha256'),
146-
'pbdkf2' => $digest = new MessageDigestPasswordEncoder('sha256'),
147-
'bcrypt_encoder' => ['algorithm' => 'bcrypt'],
148-
SomeUser::class => ['algorithm' => 'sodium', 'migrate_from' => ['bcrypt_encoder', 'digest_encoder']],
146+
SomeUser::class => ['algorithm' => 'sodium', 'migrate_from' => ['bcrypt', 'digest_encoder']],
149147
]);
150148

151149
$encoder = $factory->getEncoder(SomeUser::class);
@@ -154,6 +152,7 @@ public function testMigrateFrom()
154152
$this->assertTrue($encoder->isPasswordValid((new SodiumPasswordEncoder())->encodePassword('foo', null), 'foo', null));
155153
$this->assertTrue($encoder->isPasswordValid((new NativePasswordEncoder(null, null, null, \PASSWORD_BCRYPT))->encodePassword('foo', null), 'foo', null));
156154
$this->assertTrue($encoder->isPasswordValid($digest->encodePassword('foo', null), 'foo', null));
155+
$this->assertStringStartsWith(SODIUM_CRYPTO_PWHASH_STRPREFIX, $encoder->encodePassword('foo', null));
157156
}
158157

159158
public function testDefaultMigratingEncoders()

0 commit comments

Comments
 (0)
0