-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[DependencyInjection] Fix merging explicit tags and #[AsTaggedItem] #62329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DependencyInjection] Fix merging explicit tags and #[AsTaggedItem] #62329
Conversation
| $indexAttribute ?? '' => $attribute->index, | ||
| ]; | ||
| if (null === $defaultPriority) { | ||
| $defaultPriority = $attribute->priority ?? 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only the first php-attribute can define a default priority and default index
and defaults defined by this first php-attribute have lower priority than defaults defined by static methods (getDefaultName et al.)
Note that we'd better deprecate static methods for defaults. php-attributes are cleaner IMHO. For 8.1 I suppose.
f29141d to
074c005
Compare
811c361 to
f7e67db
Compare
f7e67db to
e31b192
Compare
nicolas-grekas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR updated, no reordering anymore, which means no behavior change when not using multiple AsTaggeditem.
This PR was merged into the 7.3 branch. Discussion ---------- [DependencyInjection] Remove unused variable | Q | A | ------------- | --- | Branch? | 7.3 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | - | License | MIT This variable became unused after #62329. Commits ------- f75f12f [DependencyInjection] Remove unused variable
Workaround a bug introduced in symfony/symfony#62329
This PR was merged into the 3.x branch. Discussion ---------- Fix tags list to use consecutive keys | Q | A | ------------- | --- | Branch? | 3.x | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | - | License | MIT Workaround a bug introduced in symfony/symfony#62329 The Symfony code incorrectly assumes that the tags array is a list. But we use `array_filter` which leaves gaps in the array keys. Fixed here by using `array_values` to reset the keys. Fix [failing job](https://github.com/symfony/monolog-bundle/actions/runs/19731209625/job/56532483316): ``` There were 3 errors: 1) Symfony\Bundle\MonologBundle\Tests\DependencyInjection\Compiler\AddProcessorsPassTest::testEmptyTagsAreIgnoredWhenNonEmptyArePresent with data set "with app channel" (array(array(), array('app')), array(array('useMicrosecondTimestamps', array('%monolog.use_microseconds%')), array('pushProcessor', array(Symfony\Component\DependencyInjection\Reference Object (...)))), array()) Undefined array key 0 /home/runner/work/monolog-bundle/monolog-bundle/vendor/symfony/dependency-injection/Compiler/PriorityTaggedServiceTrait.php:86 /home/runner/work/monolog-bundle/monolog-bundle/src/DependencyInjection/Compiler/AddProcessorsPass.php:55 /home/runner/work/monolog-bundle/monolog-bundle/vendor/symfony/dependency-injection/Compiler/Compiler.php:73 /home/runner/work/monolog-bundle/monolog-bundle/vendor/symfony/dependency-injection/ContainerBuilder.php:820 /home/runner/work/monolog-bundle/monolog-bundle/tests/DependencyInjection/Compiler/AddProcessorsPassTest.php:119 2) Symfony\Bundle\MonologBundle\Tests\DependencyInjection\Compiler\AddProcessorsPassTest::testEmptyTagsAreIgnoredWhenNonEmptyArePresent with data set "with my_channel channel" (array(array(), array('my_channel')), array(array('useMicrosecondTimestamps', array('%monolog.use_microseconds%'))), array(array('pushProcessor', array(Symfony\Component\DependencyInjection\Reference Object (...))))) Undefined array key 0 /home/runner/work/monolog-bundle/monolog-bundle/vendor/symfony/dependency-injection/Compiler/PriorityTaggedServiceTrait.php:86 /home/runner/work/monolog-bundle/monolog-bundle/src/DependencyInjection/Compiler/AddProcessorsPass.php:55 /home/runner/work/monolog-bundle/monolog-bundle/vendor/symfony/dependency-injection/Compiler/Compiler.php:73 /home/runner/work/monolog-bundle/monolog-bundle/vendor/symfony/dependency-injection/ContainerBuilder.php:820 /home/runner/work/monolog-bundle/monolog-bundle/tests/DependencyInjection/Compiler/AddProcessorsPassTest.php:119 3) Symfony\Bundle\MonologBundle\Tests\DependencyInjection\Compiler\AddProcessorsPassTest::testEmptyTagsAreIgnoredWhenNonEmptyArePresent with data set "with method and no channel" (array(array(), array('foo')), array(array('useMicrosecondTimestamps', array('%monolog.use_microseconds%')), array('pushProcessor', array(array(Symfony\Component\DependencyInjection\Reference Object (...), 'foo')))), array(array('pushProcessor', array(array(Symfony\Component\DependencyInjection\Reference Object (...), 'foo'))))) Undefined array key 0 /home/runner/work/monolog-bundle/monolog-bundle/vendor/symfony/dependency-injection/Compiler/PriorityTaggedServiceTrait.php:86 /home/runner/work/monolog-bundle/monolog-bundle/src/DependencyInjection/Compiler/AddProcessorsPass.php:55 /home/runner/work/monolog-bundle/monolog-bundle/vendor/symfony/dependency-injection/Compiler/Compiler.php:73 /home/runner/work/monolog-bundle/monolog-bundle/vendor/symfony/dependency-injection/ContainerBuilder.php:820 /home/runner/work/monolog-bundle/monolog-bundle/tests/DependencyInjection/Compiler/AddProcessorsPassTest.php:119 ``` Commits ------- 2127520 Fix tags must be a list
Instead of #62327