Skip to content

Commit d1f6daf

Browse files
committed
Merge branch '7.2' into 7.3
* 7.2: [SecurityBundle] Do not replace authenticators service by their traceable version [Finder] Fix using `==` as default operator in `DateComparator` bug #54854 [Stopwatch] undefined key error when trying to fetch a missing section [HttpFoundation] Avoid mime type guess with temp files in `BinaryFileResponse` choose the correctly cased class name for the MariaDB platform
2 parents 7ca93ab + c3f8915 commit d1f6daf

File tree

9 files changed

+66
-10
lines changed

9 files changed

+66
-10
lines changed

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

+6-4
Original file line numberDiff line numberDiff line change
@@ -643,11 +643,13 @@ private function createAuthenticationListeners(ContainerBuilder $container, stri
643643
}
644644

645645
if ($container->hasDefinition('debug.security.firewall')) {
646-
foreach ($authenticationProviders as $authenticatorId) {
647-
$container->register('debug.'.$authenticatorId, TraceableAuthenticator::class)
648-
->setDecoratedService($authenticatorId)
649-
->setArguments([new Reference('debug.'.$authenticatorId.'.inner')])
646+
foreach ($authenticationProviders as &$authenticatorId) {
647+
$traceableId = 'debug.'.$authenticatorId;
648+
$container
649+
->register($traceableId, TraceableAuthenticator::class)
650+
->setArguments([new Reference($authenticatorId)])
650651
;
652+
$authenticatorId = $traceableId;
651653
}
652654
}
653655

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

+26
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
2121
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
2222
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
23+
use Symfony\Component\DependencyInjection\Compiler\DecoratorServicePass;
2324
use Symfony\Component\DependencyInjection\Compiler\ResolveChildDefinitionsPass;
25+
use Symfony\Component\DependencyInjection\Compiler\ResolveReferencesToAliasesPass;
2426
use Symfony\Component\DependencyInjection\ContainerBuilder;
2527
use Symfony\Component\DependencyInjection\Reference;
2628
use Symfony\Component\ExpressionLanguage\Expression;
@@ -900,6 +902,30 @@ public function testCustomHasherWithMigrateFrom()
900902
]);
901903
}
902904

905+
public function testAuthenticatorsDecoration()
906+
{
907+
$container = $this->getRawContainer();
908+
$container->setParameter('kernel.debug', true);
909+
$container->getCompilerPassConfig()->setOptimizationPasses([
910+
new ResolveChildDefinitionsPass(),
911+
new DecoratorServicePass(),
912+
new ResolveReferencesToAliasesPass(),
913+
]);
914+
915+
$container->register(TestAuthenticator::class);
916+
$container->loadFromExtension('security', [
917+
'firewalls' => ['main' => ['custom_authenticator' => TestAuthenticator::class]],
918+
]);
919+
$container->compile();
920+
921+
/** @var Reference[] $managerAuthenticators */
922+
$managerAuthenticators = $container->getDefinition('security.authenticator.manager.main')->getArgument(0);
923+
$this->assertCount(1, $managerAuthenticators);
924+
$this->assertSame('debug.'.TestAuthenticator::class, (string) reset($managerAuthenticators), 'AuthenticatorManager must be injected traceable authenticators in debug mode.');
925+
926+
$this->assertTrue($container->hasDefinition(TestAuthenticator::class), 'Original authenticator must still exist in the container so it can be used outside of the AuthenticatorManager’s context.');
927+
}
928+
903929
protected function getRawContainer()
904930
{
905931
$container = new ContainerBuilder();

src/Symfony/Component/Finder/Comparator/DateComparator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct(string $test)
3636
throw new \InvalidArgumentException(\sprintf('"%s" is not a valid date.', $matches[2]));
3737
}
3838

39-
$operator = $matches[1] ?? '==';
39+
$operator = $matches[1] ?: '==';
4040
if ('since' === $operator || 'after' === $operator) {
4141
$operator = '>';
4242
}

src/Symfony/Component/Finder/Tests/Comparator/DateComparatorTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public static function getTestData()
5959
['after 2005-10-10', [strtotime('2005-10-15')], [strtotime('2005-10-09')]],
6060
['since 2005-10-10', [strtotime('2005-10-15')], [strtotime('2005-10-09')]],
6161
['!= 2005-10-10', [strtotime('2005-10-11')], [strtotime('2005-10-10')]],
62+
['2005-10-10', [strtotime('2005-10-10')], [strtotime('2005-10-11')]],
6263
];
6364
}
6465
}

src/Symfony/Component/HttpFoundation/BinaryFileResponse.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,12 @@ public function prepare(Request $request): static
189189
}
190190

191191
if (!$this->headers->has('Content-Type')) {
192-
$this->headers->set('Content-Type', $this->file->getMimeType() ?: 'application/octet-stream');
192+
$mimeType = null;
193+
if (!$this->tempFileObject) {
194+
$mimeType = $this->file->getMimeType();
195+
}
196+
197+
$this->headers->set('Content-Type', $mimeType ?: 'application/octet-stream');
193198
}
194199

195200
parent::prepare($request);

src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php

+11
Original file line numberDiff line numberDiff line change
@@ -468,4 +468,15 @@ public function testSetChunkSizeTooSmall()
468468

469469
$response->setChunkSize(0);
470470
}
471+
472+
public function testCreateFromTemporaryFileWithoutMimeType()
473+
{
474+
$file = new \SplTempFileObject();
475+
$file->fwrite('foo,bar');
476+
477+
$response = new BinaryFileResponse($file);
478+
$response->prepare(new Request());
479+
480+
$this->assertSame('application/octet-stream', $response->headers->get('Content-Type'));
481+
}
471482
}

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

+9-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Doctrine\DBAL\Connection as DBALConnection;
1616
use Doctrine\DBAL\Exception as DBALException;
1717
use Doctrine\DBAL\Platforms\AbstractPlatform;
18-
use Doctrine\DBAL\Platforms\MariaDb1060Platform;
1918
use Doctrine\DBAL\Platforms\MariaDBPlatform;
2019
use Doctrine\DBAL\Platforms\MySQL57Platform;
2120
use Doctrine\DBAL\Platforms\MySQL80Platform;
@@ -591,9 +590,16 @@ class_exists(MySQLPlatform::class) ? new MySQLPlatform() : new MySQL57Platform()
591590
'SELECT m.* FROM messenger_messages m WHERE (m.queue_name = ?) AND (m.delivered_at is null OR m.delivered_at < ?) AND (m.available_at <= ?) ORDER BY available_at ASC LIMIT 1 FOR UPDATE',
592591
];
593592

594-
if (class_exists(MariaDb1060Platform::class)) {
593+
if (interface_exists(DBALException::class)) {
594+
// DBAL 4+
595+
$mariaDbPlatformClass = 'Doctrine\DBAL\Platforms\MariaDB1060Platform';
596+
} else {
597+
$mariaDbPlatformClass = 'Doctrine\DBAL\Platforms\MariaDb1060Platform';
598+
}
599+
600+
if (class_exists($mariaDbPlatformClass)) {
595601
yield 'MariaDB106' => [
596-
new MariaDb1060Platform(),
602+
new $mariaDbPlatformClass(),
597603
'SELECT m.* FROM messenger_messages m WHERE (m.queue_name = ?) AND (m.delivered_at is null OR m.delivered_at < ?) AND (m.available_at <= ?) ORDER BY available_at ASC LIMIT 1 FOR UPDATE SKIP LOCKED',
598604
];
599605
}

src/Symfony/Component/Stopwatch/Stopwatch.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public function getEvent(string $name): StopwatchEvent
140140
*/
141141
public function getSectionEvents(string $id): array
142142
{
143-
return $this->sections[$id]->getEvents() ?? [];
143+
return isset($this->sections[$id]) ? $this->sections[$id]->getEvents() : [];
144144
}
145145

146146
/**

src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php

+5
Original file line numberDiff line numberDiff line change
@@ -187,4 +187,9 @@ public function testReset()
187187

188188
$this->assertEquals(new Stopwatch(), $stopwatch);
189189
}
190+
191+
public function testShouldReturnEmptyArrayWhenSectionMissing()
192+
{
193+
$this->assertSame([], (new Stopwatch())->getSectionEvents('missing'));
194+
}
190195
}

0 commit comments

Comments
 (0)