Skip to content

Commit 3833f88

Browse files
committed
Merge branch '4.1'
* 4.1: Move commands-specifics to a compiler pass in FWB bumped Symfony version to 4.1.5 updated VERSION for 4.1.4 updated CHANGELOG for 4.1.4 [travis] disable symfony/flex during phpunit install
2 parents 3d5629a + bc90da7 commit 3833f88

File tree

7 files changed

+179
-61
lines changed

7 files changed

+179
-61
lines changed

CHANGELOG-4.1.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,30 @@ in 4.1 minor versions.
77
To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash
88
To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v4.1.0...v4.1.1
99

10+
* 4.1.4 (2018-08-28)
11+
12+
* bug #28278 [HttpFoundation] Fix unprepared BinaryFileResponse sends empty file (wackymole)
13+
* bug #28284 [PhpUnitBridge] keep compat with composer 1.0 (nicolas-grekas)
14+
* bug #28251 [HttpFoundation] Allow RedisCluster class for RedisSessionHandler (michaelperrin)
15+
* bug #28241 [HttpKernel] fix forwarding trusted headers as server parameters (nicolas-grekas)
16+
* bug #28220 [PropertyAccess] fix type error handling when writing values (xabbuh)
17+
* bug #28249 [Cache] enable Memcached::OPT_TCP_NODELAY to fix perf of misses (nicolas-grekas)
18+
* bug #28252 [DoctrineBridge] support __toString as documented for UniqueEntityValidator (dmaicher)
19+
* bug #28216 [FrameworkBundle] `message_bus` alias public (sroze)
20+
* bug #28113 [Form] Add help texts for checkboxes in horizontal bootstrap 4 forms (apfelbox)
21+
* bug #28100 [Security] Call AccessListener after LogoutListener (chalasr)
22+
* bug #28174 Remove the HTML5 validation from the profiler URL search form (Soullivaneuh)
23+
* bug #28159 [DI] Fix autowire inner service (hason)
24+
* bug #28060 [DI] Fix false-positive circular ref leading to wrong exceptions or infinite loops at runtime (nicolas-grekas)
25+
* bug #28144 [HttpFoundation] fix false-positive ConflictingHeadersException (nicolas-grekas)
26+
* bug #28152 [Translation] fix perf of lint:xliff command (nicolas-grekas)
27+
* bug #28115 [Form] Remove extra .form-group wrapper around file widget in bootstrap 4 (MrMitch)
28+
* bug #28120 [Routing] Fixed scheme redirecting for root path (twoleds)
29+
* bug #28112 Fix CSS property typo (AhmedAbdulrahman)
30+
* bug #28012 [PropertyInfo] Allow nested collections (jderusse)
31+
* bug #28055 [PropertyInfo] Allow nested collections (jderusse)
32+
* bug #28083 Remove the Expires header when calling Response::expire() (javiereguiluz)
33+
1034
* 4.1.3 (2018-08-01)
1135

1236
* security #cve-2018-14774 [HttpKernel] fix trusted headers management in HttpCache and InlineFragmentRenderer (nicolas-grekas)
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
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+
use Symfony\Component\DependencyInjection\Reference;
17+
use Symfony\Component\Messenger\DependencyInjection\MessengerPass;
18+
19+
/**
20+
* @author Samuel Roze <samuel.roze@gmail.com>
21+
*/
22+
class MessengerCommandsPass implements CompilerPassInterface
23+
{
24+
/**
25+
* {@inheritdoc}
26+
*/
27+
public function process(ContainerBuilder $container)
28+
{
29+
if (!$container->hasDefinition('console.command.messenger_consume_messages')) {
30+
return;
31+
}
32+
33+
$buses = array();
34+
foreach ($container->findTaggedServiceIds('messenger.bus') as $busId => $tags) {
35+
$buses[$busId] = new Reference($busId);
36+
}
37+
38+
$container
39+
->getDefinition('console.command.messenger_consume_messages')
40+
->replaceArgument(3, $this->findReceiverNames($container))
41+
;
42+
}
43+
44+
private function findReceiverNames(ContainerBuilder $container)
45+
{
46+
$receiverNames = array();
47+
foreach (MessengerPass::findReceivers($container, 'messenger.receiver') as $name => $reference) {
48+
$receiverNames[(string) $reference] = $name;
49+
}
50+
51+
return array_values($receiverNames);
52+
}
53+
}

src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ContainerBuilderDebugDumpPass;
2222
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\DataCollectorTranslatorPass;
2323
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\LoggingTranslatorPass;
24+
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\MessengerCommandsPass;
2425
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ProfilerPass;
2526
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TemplatingPass;
2627
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TestServiceContainerRealRefPass;
@@ -119,6 +120,7 @@ public function build(ContainerBuilder $container)
119120
$container->addCompilerPass(new TestServiceContainerWeakRefPass(), PassConfig::TYPE_BEFORE_REMOVING, -32);
120121
$container->addCompilerPass(new TestServiceContainerRealRefPass(), PassConfig::TYPE_AFTER_REMOVING);
121122
$this->addCompilerPassIfExists($container, MessengerPass::class);
123+
$container->addCompilerPass(new MessengerCommandsPass());
122124

123125
if ($container->getParameter('kernel.debug')) {
124126
$container->addCompilerPass(new AddDebugLogProcessorPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -32);
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
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\Tests\DependencyInjection\Compiler;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\MessengerCommandsPass;
16+
use Symfony\Component\DependencyInjection\ContainerBuilder;
17+
use Symfony\Component\DependencyInjection\Reference;
18+
use Symfony\Component\Messenger\Command\ConsumeMessagesCommand;
19+
use Symfony\Component\Messenger\MessageBusInterface;
20+
use Symfony\Component\Messenger\Tests\Fixtures\DummyReceiver;
21+
use Symfony\Component\Messenger\Transport\AmqpExt\AmqpReceiver;
22+
23+
class MessengerCommandsPassTest extends TestCase
24+
{
25+
public function testItRegistersMultipleReceiversAndSetsTheReceiverNamesOnTheCommand()
26+
{
27+
$container = new ContainerBuilder();
28+
$container->register('my_bus_name', MessageBusInterface::class)->addTag('messenger.bus')->setArgument(0, array());
29+
$container->register('console.command.messenger_consume_messages', ConsumeMessagesCommand::class)->setArguments(array(
30+
null,
31+
new Reference('messenger.receiver_locator'),
32+
null,
33+
null,
34+
null,
35+
));
36+
37+
$container->register(AmqpReceiver::class, AmqpReceiver::class)->addTag('messenger.receiver', array('alias' => 'amqp'));
38+
$container->register(DummyReceiver::class, DummyReceiver::class)->addTag('messenger.receiver', array('alias' => 'dummy'));
39+
40+
(new MessengerCommandsPass())->process($container);
41+
42+
$this->assertSame(array('amqp', 'dummy'), $container->getDefinition('console.command.messenger_consume_messages')->getArgument(3));
43+
}
44+
}

src/Symfony/Component/Messenger/DependencyInjection/MessengerPass.php

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -245,30 +245,7 @@ private function guessHandledClasses(\ReflectionClass $handlerClass, string $ser
245245

246246
private function registerReceivers(ContainerBuilder $container)
247247
{
248-
$receiverMapping = array();
249-
250-
foreach ($container->findTaggedServiceIds($this->receiverTag) as $id => $tags) {
251-
$receiverClass = $container->findDefinition($id)->getClass();
252-
if (!is_subclass_of($receiverClass, ReceiverInterface::class)) {
253-
throw new RuntimeException(sprintf('Invalid receiver "%s": class "%s" must implement interface "%s".', $id, $receiverClass, ReceiverInterface::class));
254-
}
255-
256-
$receiverMapping[$id] = new Reference($id);
257-
258-
foreach ($tags as $tag) {
259-
if (isset($tag['alias'])) {
260-
$receiverMapping[$tag['alias']] = $receiverMapping[$id];
261-
}
262-
}
263-
}
264-
265-
if ($container->hasDefinition('console.command.messenger_consume_messages')) {
266-
$receiverNames = array();
267-
foreach ($receiverMapping as $name => $reference) {
268-
$receiverNames[(string) $reference] = $name;
269-
}
270-
$container->getDefinition('console.command.messenger_consume_messages')->replaceArgument(3, array_values($receiverNames));
271-
}
248+
$receiverMapping = self::findReceivers($container, $this->receiverTag);
272249

273250
$container->getDefinition('messenger.receiver_locator')->replaceArgument(0, $receiverMapping);
274251
}
@@ -337,4 +314,29 @@ private function registerBusMiddleware(ContainerBuilder $container, string $busI
337314

338315
$container->getDefinition($busId)->replaceArgument(0, $middlewareReferences);
339316
}
317+
318+
/**
319+
* @internal
320+
*/
321+
public static function findReceivers(ContainerBuilder $container, string $receiverTag)
322+
{
323+
$receiverMapping = array();
324+
325+
foreach ($container->findTaggedServiceIds($receiverTag) as $id => $tags) {
326+
$receiverClass = $container->findDefinition($id)->getClass();
327+
if (!is_subclass_of($receiverClass, ReceiverInterface::class)) {
328+
throw new RuntimeException(sprintf('Invalid receiver "%s": class "%s" must implement interface "%s".', $id, $receiverClass, ReceiverInterface::class));
329+
}
330+
331+
$receiverMapping[$id] = new Reference($id);
332+
333+
foreach ($tags as $tag) {
334+
if (isset($tag['alias'])) {
335+
$receiverMapping[$tag['alias']] = $receiverMapping[$id];
336+
}
337+
}
338+
}
339+
340+
return $receiverMapping;
341+
}
340342
}

src/Symfony/Component/Messenger/Tests/DependencyInjection/MessengerPassTest.php

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@
1818
use Symfony\Component\DependencyInjection\ContainerBuilder;
1919
use Symfony\Component\DependencyInjection\Reference;
2020
use Symfony\Component\DependencyInjection\ServiceLocator;
21-
use Symfony\Component\Messenger\Command\ConsumeMessagesCommand;
2221
use Symfony\Component\Messenger\Command\DebugCommand;
2322
use Symfony\Component\Messenger\DataCollector\MessengerDataCollector;
2423
use Symfony\Component\Messenger\DependencyInjection\MessengerPass;
25-
use Symfony\Component\Messenger\Envelope;
2624
use Symfony\Component\Messenger\Handler\ChainHandler;
2725
use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
2826
use Symfony\Component\Messenger\Handler\MessageSubscriberInterface;
@@ -35,12 +33,12 @@
3533
use Symfony\Component\Messenger\Tests\Fixtures\DummyMessage;
3634
use Symfony\Component\Messenger\Tests\Fixtures\DummyQuery;
3735
use Symfony\Component\Messenger\Tests\Fixtures\DummyQueryHandler;
36+
use Symfony\Component\Messenger\Tests\Fixtures\DummyReceiver;
3837
use Symfony\Component\Messenger\Tests\Fixtures\MultipleBusesMessage;
3938
use Symfony\Component\Messenger\Tests\Fixtures\MultipleBusesMessageHandler;
4039
use Symfony\Component\Messenger\Tests\Fixtures\SecondMessage;
4140
use Symfony\Component\Messenger\Transport\AmqpExt\AmqpReceiver;
4241
use Symfony\Component\Messenger\Transport\AmqpExt\AmqpSender;
43-
use Symfony\Component\Messenger\Transport\ReceiverInterface;
4442

4543
class MessengerPassTest extends TestCase
4644
{
@@ -237,26 +235,6 @@ public function testItRegistersReceiversWithoutTagName()
237235
$this->assertEquals(array(AmqpReceiver::class => new Reference(AmqpReceiver::class)), $container->getDefinition('messenger.receiver_locator')->getArgument(0));
238236
}
239237

240-
public function testItRegistersMultipleReceiversAndSetsTheReceiverNamesOnTheCommand()
241-
{
242-
$container = $this->getContainerBuilder();
243-
$container->register('console.command.messenger_consume_messages', ConsumeMessagesCommand::class)->setArguments(array(
244-
null,
245-
new Reference('messenger.receiver_locator'),
246-
null,
247-
null,
248-
null,
249-
));
250-
251-
$container->register(AmqpReceiver::class, AmqpReceiver::class)->addTag('messenger.receiver', array('alias' => 'amqp'));
252-
$container->register(DummyReceiver::class, DummyReceiver::class)->addTag('messenger.receiver', array('alias' => 'dummy'));
253-
254-
(new MessengerPass())->process($container);
255-
256-
$this->assertSame(array('amqp', 'dummy'), $container->getDefinition('console.command.messenger_consume_messages')->getArgument(3));
257-
$this->assertSame(array('message_bus'), $container->getDefinition('console.command.messenger_consume_messages')->getArgument(4));
258-
}
259-
260238
public function testItRegistersSenders()
261239
{
262240
$container = $this->getContainerBuilder();
@@ -631,20 +609,6 @@ public function __invoke(DummyMessage $message): void
631609
}
632610
}
633611

634-
class DummyReceiver implements ReceiverInterface
635-
{
636-
public function receive(callable $handler): void
637-
{
638-
for ($i = 0; $i < 3; ++$i) {
639-
$handler(Envelope::wrap(new DummyMessage("Dummy $i")));
640-
}
641-
}
642-
643-
public function stop(): void
644-
{
645-
}
646-
}
647-
648612
class InvalidReceiver
649613
{
650614
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
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\Component\Messenger\Tests\Fixtures;
13+
14+
use Symfony\Component\Messenger\Envelope;
15+
use Symfony\Component\Messenger\Transport\ReceiverInterface;
16+
17+
class DummyReceiver implements ReceiverInterface
18+
{
19+
public function receive(callable $handler): void
20+
{
21+
for ($i = 0; $i < 3; ++$i) {
22+
$handler(Envelope::wrap(new DummyMessage("Dummy $i")));
23+
}
24+
}
25+
26+
public function stop(): void
27+
{
28+
}
29+
}

0 commit comments

Comments
 (0)