10000 [2.8][Container] UnusedTagsPass Warning · Issue #16908 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[2.8][Container] UnusedTagsPass Warning #16908

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

Closed
Haehnchen opened this issue Dec 8, 2015 · 4 comments
Closed

[2.8][Container] UnusedTagsPass Warning #16908

Haehnchen opened this issue Dec 8, 2015 · 4 comments

Comments

@Haehnchen
Copy link
Contributor

Just updated one of my projects from Symfony2.7 to 2.8 and now am getting the following error multiple times inside UnusedTagsPass. What ever there is wrong configurated by a bundle or so (sry, not checked in detail), should not run into this condition. UnusedTagsPass is just a logger which should catch this issue.

EDIT
Found following usage. Should we protect this?

<tag channel="foo"/>
ContextErrorException in UnusedTagsPass.php line 73: Warning: strpos(): Empty needle

Simple workaround. :)

      foreach ($container->findUnusedTags() as $tag) {
            // skip whitelisted tags
            if (!$tag || in_array($tag, $this->whitelist)) {
in UnusedTagsPass.php line 73
at ErrorHandler->handleError('2', 'strpos(): Empty needle', '/.../src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/UnusedTagsPass.php', '73', array('container' => object(ContainerBuilder), 'compiler' => object(Compiler), 'formatter' => object(LoggingFormatter), 'tags' => array('twig.loader', 'monolog.logger', 'console.command', 'kernel.event_subscriber', 'data_collector', 'knp_menu.renderer', 'knp_menu.voter', 'kernel.event_listener', 'twig.extension', 'knp_paginator.subscriber', 'fos_elastica.index', 'knp_menu.menu', 'form.type', ....'serializer.normalizer'), 'tag' => '', 'candidates' => array(), 'definedTag' => 'twig.loader', 'this' => object(UnusedTagsPass)))
at strpos('twig.loader', '') in UnusedTagsPass.php line 73
at UnusedTagsPass->process(object(ContainerBuilder)) in Compiler.php line 107
at Compiler->compile(object(ContainerBuilder)) in ContainerBuilder.php line 589
at ContainerBuilder->compile() in Kernel.php line 511
at Kernel->initializeContainer() in Kernel.php line 133
at Kernel->boot() in Kernel.php line 182
at Kernel->handle(object(Request)) in app_dev.php line 31
@xabbuh
Copy link
Member
xabbuh commented Dec 9, 2015

Status: Reviewed

@xabbuh
Copy link
Member
xabbuh commented Dec 9, 2015

see #16932

@xabbuh
Copy link
Member
xabbuh commented Dec 10, 2015

I had a look at this again and I think the actual issue is that the XmlFileLoader does not enforce the tags to have a name (the YamlFileLoader actually has a test to enforce this behaviour, see https://github.com/symfony/symfony/blob/master/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php#L224-L234). So I opened #16956 to enforce the same behaviour in the XmlFileLoader too and changed #16932 to simply ignore tags without a name (in case someone wrongly created tags this way manually).

@aitboudad
Copy link
Contributor

the issue occurs too if the tag name is empty

tags: [{ name: ''}]

fabpot added a commit that referenced this issue Jan 28, 2016
…a name (xabbuh)

This PR was merged into the 2.3 branch.

Discussion
----------

[DependencyInjection] XmlFileLoader: enforce tags to have a name

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #16908
| License       | MIT
| Doc PR        |

Commits
-------

d86a3a7 [DependencyInjection] enforce tags to have a name
@fabpot fabpot closed this as completed Jan 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants
0