Skip to content

Commit 51b99e2

Browse files
committed
Merge branch '6.4' into 7.1
* 6.4: relax assertions on generated hashes [Messenger] ensure exception on rollback does not hide previous exception require the writer to implement getFormats() in the translation:extract don't require fake notifier transports to be installed as non-dev dependencies Remove 5.4 branch from PR template [Scheduler] Fix optional count variable in testGetNextRunDates
2 parents de5d4a9 + 17d8ae2 commit 51b99e2

File tree

5 files changed

+54
-11
lines changed

5 files changed

+54
-11
lines changed

Command/TranslationUpdateCommand.php

+4
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ public function __construct(
6262
private array $enabledLocales = [],
6363
) {
6464
parent::__construct();
65+
66+
if (!method_exists($writer, 'getFormats')) {
67+
throw new \InvalidArgumentException(sprintf('The writer class "%s" does not implement the "getFormats()" method.', $writer::class));
68+
}
6569
}
6670

6771
protected function configure(): void
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
13+
14+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15+
use Symfony\Component\DependencyInjection\ContainerBuilder;
16+
17+
class TranslationUpdateCommandPass implements CompilerPassInterface
18+
{
19+
public function process(ContainerBuilder $container): void
20+
{
21+
if (!$container->hasDefinition('console.command.translation_extract')) {
22+
return;
23+
}
24+
25+
$translationWriterClass = $container->getParameterBag()->resolveValue($container->findDefinition('translation.writer')->getClass());
26+
27+
if (!method_exists($translationWriterClass, 'getFormats')) {
28+
$container->removeDefinition('console.command.translation_extract');
29+
}
30+
}
31+
}

DependencyInjection/FrameworkExtension.php

+16-10
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@
120120
use Symfony\Component\Mime\MimeTypeGuesserInterface;
121121
use Symfony\Component\Mime\MimeTypes;
122122
use Symfony\Component\Notifier\Bridge as NotifierBridge;
123+
use Symfony\Component\Notifier\Bridge\FakeChat\FakeChatTransportFactory;
124+
use Symfony\Component\Notifier\Bridge\FakeSms\FakeSmsTransportFactory;
123125
use Symfony\Component\Notifier\ChatterInterface;
124126
use Symfony\Component\Notifier\Notifier;
125127
use Symfony\Component\Notifier\Recipient\Recipient;
@@ -2762,8 +2764,6 @@ private function registerNotifierConfiguration(array $config, ContainerBuilder $
27622764
NotifierBridge\Engagespot\EngagespotTransportFactory::class => 'notifier.transport_factory.engagespot',
27632765
NotifierBridge\Esendex\EsendexTransportFactory::class => 'notifier.transport_factory.esendex',
27642766
NotifierBridge\Expo\ExpoTransportFactory::class => 'notifier.transport_factory.expo',
2765-
NotifierBridge\FakeChat\FakeChatTransportFactory::class => 'notifier.transport_factory.fake-chat',
2766-
NotifierBridge\FakeSms\FakeSmsTransportFactory::class => 'notifier.transport_factory.fake-sms',
27672767
NotifierBridge\Firebase\FirebaseTransportFactory::class => 'notifier.transport_factory.firebase',
27682768
NotifierBridge\FortySixElks\FortySixElksTransportFactory::class => 'notifier.transport_factory.forty-six-elks',
27692769
NotifierBridge\FreeMobile\FreeMobileTransportFactory::class => 'notifier.transport_factory.free-mobile',
@@ -2847,20 +2847,26 @@ private function registerNotifierConfiguration(array $config, ContainerBuilder $
28472847
$container->removeDefinition($classToServices[NotifierBridge\Mercure\MercureTransportFactory::class]);
28482848
}
28492849

2850-
if (ContainerBuilder::willBeAvailable('symfony/fake-chat-notifier', NotifierBridge\FakeChat\FakeChatTransportFactory::class, ['symfony/framework-bundle', 'symfony/notifier', 'symfony/mailer'])) {
2851-
$container->getDefinition($classToServices[NotifierBridge\FakeChat\FakeChatTransportFactory::class])
2852-
->replaceArgument(0, new Reference('mailer'))
2853-
->replaceArgument(1, new Reference('logger'))
2850+
// don't use ContainerBuilder::willBeAvailable() as these are not needed in production
2851+
if (class_exists(FakeChatTransportFactory::class)) {
2852+
$container->getDefinition('notifier.transport_factory.fake-chat')
2853+
->replaceArgument(0, new Reference('mailer', ContainerBuilder::NULL_ON_INVALID_REFERENCE))
2854+
->replaceArgument(1, new Reference('logger', ContainerBuilder::NULL_ON_INVALID_REFERENCE))
28542855
->addArgument(new Reference('event_dispatcher', ContainerBuilder::NULL_ON_INVALID_REFERENCE))
28552856
->addArgument(new Reference('http_client', ContainerBuilder::NULL_ON_INVALID_REFERENCE));
2857+
} else {
2858+
$container->removeDefinition('notifier.transport_factory.fake-chat');
28562859
}
28572860

2858-
if (ContainerBuilder::willBeAvailable('symfony/fake-sms-notifier', NotifierBridge\FakeSms\FakeSmsTransportFactory::class, ['symfony/framework-bundle', 'symfony/notifier', 'symfony/mailer'])) {
2859-
$container->getDefinition($classToServices[NotifierBridge\FakeSms\FakeSmsTransportFactory::class])
2860-
->replaceArgument(0, new Reference('mailer'))
2861-
->replaceArgument(1, new Reference('logger'))
2861+
// don't use ContainerBuilder::willBeAvailable() as these are not needed in production
2862+
if (class_exists(FakeSmsTransportFactory::class)) {
2863+
$container->getDefinition('notifier.transport_factory.fake-sms')
2864+
->replaceArgument(0, new Reference('mailer', ContainerBuilder::NULL_ON_INVALID_REFERENCE))
2865+
->replaceArgument(1, new Reference('logger', ContainerBuilder::NULL_ON_INVALID_REFERENCE))
28622866
->addArgument(new Reference('event_dispatcher', ContainerBuilder::NULL_ON_INVALID_REFERENCE))
28632867
->addArgument(new Reference('http_client', ContainerBuilder::NULL_ON_INVALID_REFERENCE));
2868+
} else {
2869+
$container->removeDefinition('notifier.transport_factory.fake-sms');
28642870
}
28652871

28662872
if (ContainerBuilder::willBeAvailable('symfony/bluesky-notifier', NotifierBridge\Bluesky\BlueskyTransportFactory::class, ['symfony/framework-bundle', 'symfony/notifier'])) {

FrameworkBundle.php

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\RemoveUnusedSessionMarshallingHandlerPass;
2020
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TestServiceContainerRealRefPass;
2121
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TestServiceContainerWeakRefPass;
22+
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslationUpdateCommandPass;
2223
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\UnusedTagsPass;
2324
use Symfony\Bundle\FrameworkBundle\DependencyInjection\VirtualRequestStackPass;
2425
use Symfony\Component\Cache\Adapter\ApcuAdapter;
@@ -181,6 +182,7 @@ public function build(ContainerBuilder $container): void
181182
// must be registered after MonologBundle's LoggerChannelPass
182183
$container->addCompilerPass(new ErrorLoggerCompilerPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -32);
183184
$container->addCompilerPass(new VirtualRequestStackPass());
185+
$container->addCompilerPass(new TranslationUpdateCommandPass(), PassConfig::TYPE_BEFORE_REMOVING);
184186

185187
if ($container->getParameter('kernel.debug')) {
186188
$container->addCompilerPass(new AddDebugLogProcessorPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 2);

Tests/Functional/FragmentTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ public function testGenerateFragmentUri()
5050
$client = self::createClient(['test_case' => 'Fragment', 'root_config' => 'config.yml', 'debug' => true]);
5151
$client->request('GET', '/fragment_uri');
5252

53-
$this->assertSame('/_fragment?_hash=CCRGN2D%2FoAJbeGz%2F%2FdoH3bNSPwLCrmwC1zAYCGIKJ0E%3D&_path=_format%3Dhtml%26_locale%3Den%26_controller%3DSymfony%255CBundle%255CFrameworkBundle%255CTests%255CFunctional%255CBundle%255CTestBundle%255CController%255CFragmentController%253A%253AindexAction', $client->getResponse()->getContent());
53+
$this->assertMatchesRegularExpression('#/_fragment\?_hash=.+&_path=_format%3Dhtml%26_locale%3Den%26_controller%3DSymfony%255CBundle%255CFrameworkBundle%255CTests%255CFunctional%255CBundle%255CTestBundle%255CController%255CFragmentController%253A%253AindexAction$#', $client->getResponse()->getContent());
5454
}
5555
}

0 commit comments

Comments
 (0)