Skip to content

Commit 60f5bdb

Browse files
Prevent double registrations related to tag priorities
1 parent 578d514 commit 60f5bdb

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

DependencyInjection/Compiler/SerializerPass.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,9 @@ private function findAndSortTaggedServices($tagName, ContainerBuilder $container
4747
}
4848

4949
$sortedServices = array();
50-
foreach ($services as $serviceId => $tags) {
51-
foreach ($tags as $tag) {
52-
$priority = isset($tag['priority']) ? $tag['priority'] : 0;
53-
$sortedServices[$priority][] = new Reference($serviceId);
54-
}
50+
foreach ($services as $serviceId => $attributes) {
51+
$priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0;
52+
$sortedServices[$priority][] = new Reference($serviceId);
5553
}
5654

5755
krsort($sortedServices);

Tests/DependencyInjection/Compiler/SerializerPassTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ public function testThrowExceptionWhenNoEncoders()
7272
public function testServicesAreOrderedAccordingToPriority()
7373
{
7474
$services = array(
75-
'n3' => array('tag' => array()),
76-
'n1' => array('tag' => array('priority' => 200)),
77-
'n2' => array('tag' => array('priority' => 100)),
75+
'n3' => array(array()),
76+
'n1' => array(array('priority' => 200)),
77+
'n2' => array(array('priority' => 100)),
7878
);
7979

8080
$expected = array(

0 commit comments

Comments
 (0)