Skip to content

Commit

Permalink
Merge pull request #1159 from nicolas-grekas/msg
Browse files Browse the repository at this point in the history
Fix compat with Messenger 5.1
  • Loading branch information
alcaeus authored Apr 29, 2020
2 parents a620214 + ae9cf2e commit 98e038d
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 7 deletions.
4 changes: 3 additions & 1 deletion DependencyInjection/Compiler/WellKnownSchemaFilterPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler;
use Symfony\Component\Lock\Store\PdoStore;
use Symfony\Component\Messenger\Transport\Doctrine\Connection;
use Symfony\Component\Messenger\Bridge\Doctrine\Transport\Connection;
use Symfony\Component\Messenger\Transport\Doctrine\Connection as LegacyConnection;

/**
* Blacklist tables used by well-known Symfony classes.
Expand Down Expand Up @@ -39,6 +40,7 @@ public function process(ContainerBuilder $container)
$blacklist[] = $definition->getArguments()[1]['db_table'] ?? 'lock_keys';
break;

case LegacyConnection::class:
case Connection::class:
$blacklist[] = $definition->getArguments()[0]['table_name'] ?? 'messenger_messages';
break;
Expand Down
9 changes: 7 additions & 2 deletions Tests/DependencyInjection/AbstractDoctrineExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,9 @@ public function testResolveTargetEntity() : void
$definition = $container->getDefinition('doctrine.orm.listeners.resolve_target_entity');
$this->assertDICDefinitionMethodCallOnce($definition, 'addResolveTargetEntity', ['Symfony\Component\Security\Core\User\UserInterface', 'MyUserClass', []]);

$this->assertEquals(['doctrine.event_subscriber' => [[]]], $definition->getTags());
$tags = $definition->getTags();
unset($tags['container.no_preload']);
$this->assertEquals(['doctrine.event_subscriber' => [[]]], $tags);
}

public function testAttachEntityListeners() : void
Expand All @@ -655,7 +657,9 @@ public function testAttachEntityListeners() : void
$methodCalls = $definition->getMethodCalls();

$this->assertDICDefinitionMethodCallCount($definition, 'addEntityListener', [], 6);
$this->assertEquals(['doctrine.event_listener' => [ ['event' => 'loadClassMetadata'] ] ], $definition->getTags());
$tags = $definition->getTags();
unset($tags['container.no_preload']);
$this->assertEquals(['doctrine.event_listener' => [ ['event' => 'loadClassMetadata'] ] ], $tags);

$this->assertEquals($methodCalls[0], [
'addEntityListener',
Expand Down Expand Up @@ -790,6 +794,7 @@ public static function dataWellKnownSchemaFilterServices()
yield ['cache', 'cache_items'];
yield ['lock', 'lock_keys'];
yield ['messenger', 'messenger_messages'];
yield ['messenger_legacy', 'messenger_messages'];
yield ['session', 'sessions'];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@

<srv:services>
<srv:service id="well_known_filter" alias="doctrine.dbal.well_known_schema_asset_filter" public="true" />
<srv:service id="symfony.messenger" class="Symfony\Component\Messenger\Transport\Doctrine\Connection" />
<srv:service id="symfony.messenger" class="Symfony\Component\Messenger\Bridge\Doctrine\Transport\Connection" />
</srv:services>
</srv:container>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" ?>

<srv:container xmlns="http://symfony.com/schema/dic/doctrine"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:srv="http://symfony.com/schema/dic/services"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">

<config>
<dbal default-connection="connection1">
<connection name="connection1" schema-filter="~^(?!t_)~" />
<connection name="connection2" />
<connection name="connection3" />
</dbal>
</config>

<srv:services>
<srv:service id="well_known_filter" alias="doctrine.dbal.well_known_schema_asset_filter" public="true" />
<srv:service id="symfony.messenger" class="Symfony\Component\Messenger\Transport\Doctrine\Connection" />
</srv:services>
</srv:container>
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<srv:services>
<srv:service id="well_known_filter" alias="doctrine.dbal.well_known_schema_asset_filter" public="true" />
<srv:service id="symfony.messenger" class="Symfony\Component\Messenger\Transport\Doctrine\Connection">
<srv:service id="symfony.messenger" class="Symfony\Component\Messenger\Bridge\Doctrine\Transport\Connection">
<srv:argument type="collection">
<srv:argument key="table_name">app_messages</srv:argument>
</srv:argument>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" ?>

<srv:container xmlns="http://symfony.com/schema/dic/doctrine"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:srv="http://symfony.com/schema/dic/services"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">

<config>
<dbal default-connection="connection1">
<connection name="connection1" schema-filter="~^(?!t_)~" />
<connection name="connection2" />
<connection name="connection3" />
</dbal>
</config>

<srv:services>
<srv:service id="well_known_filter" alias="doctrine.dbal.well_known_schema_asset_filter" public="true" />
<srv:service id="symfony.messenger" class="Symfony\Component\Messenger\Transport\Doctrine\Connection">
<srv:argument type="collection">
<srv:argument key="table_name">app_messages</srv:argument>
</srv:argument>
</srv:service>
</srv:services>
</srv:container>
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ services:
public: true

symfony.messenger:
class: 'Symfony\Component\Messenger\Transport\Doctrine\Connection'
class: 'Symfony\Component\Messenger\Bridge\Doctrine\Transport\Connection'
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
doctrine:
dbal:
default_connection: connection1
connections:
connection1:
schema_filter: ~^(?!t_)~
connection2: []
connection3: []

services:
well_known_filter:
alias: 'doctrine.dbal.well_known_schema_asset_filter'
public: true

symfony.messenger:
class: 'Symfony\Component\Messenger\Transport\Doctrine\Connection'
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ services:
public: true

symfony.messenger:
class: 'Symfony\Component\Messenger\Transport\Doctrine\Connection'
class: 'Symfony\Component\Messenger\Bridge\Doctrine\Transport\Connection'
arguments:
- table_name: app_messages
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
doctrine:
dbal:
default_connection: connection1
connections:
connection1:
schema_filter: ~^(?!t_)~
connection2: []
connection3: []

services:
well_known_filter:
alias: 'doctrine.dbal.well_known_schema_asset_filter'
public: true

symfony.messenger:
class: 'Symfony\Component\Messenger\Transport\Doctrine\Connection'
arguments:
- table_name: app_messages

0 comments on commit 98e038d

Please sign in to comment.