[2.8] Prevent double registrations related to tag priorities

This commit is contained in:
Nicolas Grekas 2017-04-12 17:21:47 +02:00
parent 6edd08d7c5
commit 2be5821743
2 changed files with 6 additions and 8 deletions

View File

@ -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)) {

View File

@ -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(