From 2be582174375e6377af8504560624f840a98580d Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 12 Apr 2017 17:21:47 +0200 Subject: [PATCH] [2.8] Prevent double registrations related to tag priorities --- .../DependencyInjection/Compiler/PropertyInfoPass.php | 8 +++----- .../DependencyInjection/Compiler/PropertyInfoPassTest.php | 6 +++--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/PropertyInfoPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/PropertyInfoPass.php index 819827ac8c..589af52fd6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/PropertyInfoPass.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/PropertyInfoPass.php @@ -57,11 +57,9 @@ class PropertyInfoPass implements CompilerPassInterface $services = $container->findTaggedServiceIds($tagName); $sortedServices = array(); - foreach ($services as $serviceId => $tags) { - foreach ($tags as $attributes) { - $priority = isset($attributes['priority']) ? $attributes['priority'] : 0; - $sortedServices[$priority][] = new Reference($serviceId); - } + foreach ($services as $serviceId => $attributes) { + $priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0; + $sortedServices[$priority][] = new Reference($serviceId); } if (empty($sortedServices)) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/PropertyInfoPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/PropertyInfoPassTest.php index 46b7b57102..a7801e0f69 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/PropertyInfoPassTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/PropertyInfoPassTest.php @@ -20,9 +20,9 @@ class PropertyInfoPassTest extends TestCase public function testServicesAreOrderedAccordingToPriority() { $services = array( - 'n3' => array('tag' => array()), - 'n1' => array('tag' => array('priority' => 200)), - 'n2' => array('tag' => array('priority' => 100)), + 'n3' => array(array()), + 'n1' => array(array('priority' => 200)), + 'n2' => array(array('priority' => 100)), ); $expected = array(