Skip to content

Conversation

@GromNaN
Copy link
Member

@GromNaN GromNaN commented Dec 7, 2025

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:

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

Workaround a bug introduced in symfony/symfony#62329
@GromNaN GromNaN merged commit 344f262 into symfony:3.x Dec 7, 2025
9 checks passed
@GromNaN GromNaN deleted the fix-tags-index branch December 7, 2025 22:52
nicolas-grekas added a commit to symfony/symfony that referenced this pull request Dec 8, 2025
…n tag attributes are not a list (GromNaN)

This PR was merged into the 7.3 branch.

Discussion
----------

[DependencyInjection] Fix `PriorityTaggedServiceTrait` when tag attributes are not a list

| Q             | A
| ------------- | ---
| Branch?       | 7.3
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | -
| License       | MIT

Alternative to #62683

Ensure the attributes of the tag are in a list before iterating on them using sequential indexes.

> In symfony/monolog-bundle#485, the tag attributes are filtered, which generates gaps in the keys. The PR mentioned above causes MonologBundle to fail. This can be fixed by symfony/monolog-bundle#563. However I believe the issue should also be addressed in Symfony.

Commits
-------

5a4a036 [DependencyInjection] Fix PriorityTaggedServiceTrait when tag attributes are not a list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants