Skip to content

Commit 5a74790

Browse files
committed
Merge branch '5.1'
* 5.1: fix forward compatibility with Doctrine DBAL 2.11+ [SecurityBundle] Fix the session listener registration under the new authentication manager allow cursor to be used even when STDIN is not defined
2 parents bf53b26 + 0b19249 commit 5a74790

File tree

5 files changed

+55
-23
lines changed

5 files changed

+55
-23
lines changed

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,6 @@ public function load(array $configs, ContainerBuilder $container)
168168
$container->getDefinition('security.authentication.guard_handler')
169169
->replaceArgument(2, $this->statelessFirewallKeys);
170170

171-
if ($this->authenticatorManagerEnabled) {
172-
foreach ($this->statelessFirewallKeys as $statelessFirewallId) {
173-
$container
174-
->setDefinition('security.listener.session.'.$statelessFirewallId, new ChildDefinition('security.listener.session'))
175-
->addTag('kernel.event_subscriber', ['dispatcher' => 'security.event_dispatcher.'.$statelessFirewallId]);
176-
}
177-
}
178-
179171
if ($config['encoders']) {
180172
$this->createEncoders($config['encoders'], $container);
181173
}
@@ -373,6 +365,12 @@ private function createFirewall(ContainerBuilder $container, string $id, array $
373365
$contextKey = $firewall['context'] ?? $id;
374366
$listeners[] = new Reference($contextListenerId = $this->createContextListener($container, $contextKey));
375367
$sessionStrategyId = 'security.authentication.session_strategy';
368+
369+
if ($this->authenticatorManagerEnabled) {
370+
$container
371+
->setDefinition('security.listener.session.'.$id, new ChildDefinition('security.listener.session'))
372+
->addTag('kernel.event_subscriber', ['dispatcher' => $firewallEventDispatcherId]);
373+
}
376374
} else {
377375
$this->statelessFirewallKeys[] = $id;
378376
$sessionStrategyId = 'security.authentication.session_strategy_noop';

src/Symfony/Bundle/SecurityBundle/Resources/config/security_authenticator.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
class="Symfony\Component\Security\Http\EventListener\SessionStrategyListener"
6464
abstract="true">
6565
<argument type="service" id="security.authentication.session_strategy" />
66-
<argument type="abstract">stateless firewall keys</argument>
6766
</service>
6867

6968
<service id="security.listener.remember_me"

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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,48 @@ public function provideConfigureCustomAuthenticatorData()
559559
];
560560
}
561561

562+
public function testCompilesWithoutSessionListenerWithStatelessFirewallWithAuthenticationManager()
563+
{
564+
$container = $this->getRawContainer();
565+
566+
$firewallId = 'stateless_firewall';
567+
$container->loadFromExtension('security', [
568+
'enable_authenticator_manager' => true,
569+
'firewalls' => [
570+
$firewallId => [
571+
'pattern' => '/.*',
572+
'stateless' => true,
573+
'http_basic' => null,
574+
],
575+
],
576+
]);
577+
578+
$container->compile();
579+
580+
$this->assertFalse($container->has('security.listener.session.'.$firewallId));
581+
}
582+
583+
public function testCompilesWithSessionListenerWithStatefulllFirewallWithAuthenticationManager()
584+
{
585+
$container = $this->getRawContainer();
586+
587+
$firewallId = 'statefull_firewall';
588+
$container->loadFromExtension('security', [
589+
'enable_authenticator_manager' => true,
590+
'firewalls' => [
591+
$firewallId => [
592+
'pattern' => '/.*',
593+
'stateless' => false,
594+
'http_basic' => null,
595+
],
596+
],
597+
]);
598+
599+
$container->compile();
600+
601+
$this->assertTrue($container->has('security.listener.session.'.$firewallId));
602+
}
603+
562604
protected function getRawContainer()
563605
{
564606
$container = new ContainerBuilder();

src/Symfony/Component/Console/Cursor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ final class Cursor
2121
private $output;
2222
private $input;
2323

24-
public function __construct(OutputInterface $output, $input = STDIN)
24+
public function __construct(OutputInterface $output, $input = null)
2525
{
2626
$this->output = $output;
27-
$this->input = $input;
27+
$this->input = $input ?? (\defined('STDIN') ? STDIN : fopen('php://input', 'r+'));
2828
}
2929

3030
public function moveUp(int $lines = 1): self

src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/ConnectionTest.php

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313

1414
use Doctrine\DBAL\DBALException;
1515
use Doctrine\DBAL\Driver\ResultStatement;
16-
use Doctrine\DBAL\ForwardCompatibility\Driver\ResultStatement as ForwardCompatibleResultStatement;
1716
use Doctrine\DBAL\Platforms\AbstractPlatform;
1817
use Doctrine\DBAL\Query\QueryBuilder;
1918
use Doctrine\DBAL\Schema\AbstractSchemaManager;
2019
use Doctrine\DBAL\Schema\Schema;
2120
use Doctrine\DBAL\Schema\SchemaConfig;
2221
use Doctrine\DBAL\Schema\Synchronizer\SchemaSynchronizer;
22+
use Doctrine\DBAL\Statement;
2323
use PHPUnit\Framework\TestCase;
2424
use Symfony\Component\Messenger\Bridge\Doctrine\Tests\Fixtures\DummyMessage;
2525
use Symfony\Component\Messenger\Bridge\Doctrine\Transport\Connection;
@@ -146,14 +146,10 @@ private function getQueryBuilderMock()
146146

147147
private function getStatementMock($expectedResult): ResultStatement
148148
{
149-
$mockedInterface = interface_exists(ForwardCompatibleResultStatement::class)
150-
? ForwardCompatibleResultStatement::class
151-
: ResultStatement::class;
152-
153-
$stmt = $this->createMock($mockedInterface);
149+
$stmt = $this->createMock(Statement::class);
154150

155151
$stmt->expects($this->once())
156-
->method(method_exists($mockedInterface, 'fetchAssociative') ? 'fetchAssociative' : 'fetch')
152+
->method(method_exists(Statement::class, 'fetchAssociative') ? 'fetchAssociative' : 'fetch')
157153
->willReturn($expectedResult);
158154

159155
return $stmt;
@@ -315,12 +311,9 @@ public function testFindAll()
315311
'headers' => json_encode(['type' => DummyMessage::class]),
316312
];
317313

318-
$mockedInterface = interface_exists(ForwardCompatibleResultStatement::class)
319-
? ForwardCompatibleResultStatement::class
320-
: ResultStatement::class;
321-
$stmt = $this->createMock($mockedInterface);
314+
$stmt = $this->createMock(Statement::class);
322315
$stmt->expects($this->once())
323-
->method(method_exists($mockedInterface, 'fetchAllAssociative') ? 'fetchAllAssociative' : 'fetchAll')
316+
->method(method_exists(Statement::class, 'fetchAllAssociative') ? 'fetchAllAssociative' : 'fetchAll')
324317
->willReturn([$message1, $message2]);
325318

326319
$driverConnection

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy