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

Missing default command name in DI tags #126

Closed
johmanx10 opened this Issue Dec 1, 2017 · 10 comments

Comments

Projects
None yet
3 participants
@johmanx10

johmanx10 commented Dec 1, 2017

As I just installed Symfony 3.4, I get the following error:

Call to undefined method Doctrine\Bundle\DoctrineCacheBundle\Command\ContainsCommand::getDefaultName()

I believe this can be solved by updating the tags for the service definitions of the commands in Resources/services.xml

<services>
        <service id="doctrine_cache.contains_command" class="Doctrine\Bundle\DoctrineCacheBundle\Command\ContainsCommand">
            <tag name="console.command" />
        </service>
        <service id="doctrine_cache.delete_command" class="Doctrine\Bundle\DoctrineCacheBundle\Command\DeleteCommand">
            <tag name="console.command" />
        </service>
        <service id="doctrine_cache.flush_command" class="Doctrine\Bundle\DoctrineCacheBundle\Command\FlushCommand">
            <tag name="console.command" />
        </service>
        <service id="doctrine_cache.stats_command" class="Doctrine\Bundle\DoctrineCacheBundle\Command\StatsCommand">
            <tag name="console.command" />
        </service>
</services>

Would become:

<services>
        <service id="doctrine_cache.contains_command" class="Doctrine\Bundle\DoctrineCacheBundle\Command\ContainsCommand">
            <tag name="console.command" command="doctrine:cache:contains" />
        </service>
        <service id="doctrine_cache.delete_command" class="Doctrine\Bundle\DoctrineCacheBundle\Command\DeleteCommand">
            <tag name="console.command" command="doctrine:cache:delete" />
        </service>
        <service id="doctrine_cache.flush_command" class="Doctrine\Bundle\DoctrineCacheBundle\Command\FlushCommand">
            <tag name="console.command" command="doctrine:cache:flush" />
        </service>
        <service id="doctrine_cache.stats_command" class="Doctrine\Bundle\DoctrineCacheBundle\Command\StatsCommand">
            <tag name="console.command" command="doctrine:cache:stats" />
        </service>
</services>
@alcaeus

This comment has been minimized.

Show comment
Hide comment
@alcaeus

alcaeus Dec 1, 2017

Member

@johmanx10 do you have a stack trace for the error above?

Member

alcaeus commented Dec 1, 2017

@johmanx10 do you have a stack trace for the error above?

@johmanx10

This comment has been minimized.

Show comment
Hide comment
@johmanx10

johmanx10 Dec 1, 2017

@alcaeus here is a redacted stack trace:

PHP Fatal error:  Uncaught Error: Call to undefined method Doctrine\Bundle\DoctrineCacheBundle\Command\ContainsCommand::getDefaultName() in vendor/symfony/symfony/src/Symfony/Component/Console/DependencyInjection/AddConsoleCommandPass.php:61
Stack trace:
#0 vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/Compiler.php(141): Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass->process(Object(Symfony\Component\DependencyInjection\ContainerBuilder))
#1 vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php(760): Symfony\Component\DependencyInjection\Compiler\Compiler->compile(Object(Symfony\Component\DependencyInjection\ContainerBuilder))
#2 vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(625): Symfony\Component\DependencyInjection\ContainerBuilder->compile()
#3 vendor/symfony/symfony/src/Symfony/Component/Console/DependencyInjection/AddConsoleCommandPass.php on line 61

johmanx10 commented Dec 1, 2017

@alcaeus here is a redacted stack trace:

PHP Fatal error:  Uncaught Error: Call to undefined method Doctrine\Bundle\DoctrineCacheBundle\Command\ContainsCommand::getDefaultName() in vendor/symfony/symfony/src/Symfony/Component/Console/DependencyInjection/AddConsoleCommandPass.php:61
Stack trace:
#0 vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/Compiler.php(141): Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass->process(Object(Symfony\Component\DependencyInjection\ContainerBuilder))
#1 vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php(760): Symfony\Component\DependencyInjection\Compiler\Compiler->compile(Object(Symfony\Component\DependencyInjection\ContainerBuilder))
#2 vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(625): Symfony\Component\DependencyInjection\ContainerBuilder->compile()
#3 vendor/symfony/symfony/src/Symfony/Component/Console/DependencyInjection/AddConsoleCommandPass.php on line 61
@chalasr

This comment has been minimized.

Show comment
Hide comment
@chalasr

chalasr Dec 1, 2017

Contributor

I can't reproduce, can you please paste the output of composer show?

Contributor

chalasr commented Dec 1, 2017

I can't reproduce, can you please paste the output of composer show?

@chalasr

This comment has been minimized.

Show comment
Hide comment
@chalasr

chalasr Dec 1, 2017

Contributor

Command::getDefaultName() has been introduced in symfony/console:3.4, this should not happen. Perhaps a cache issue after upgrading?

Contributor

chalasr commented Dec 1, 2017

Command::getDefaultName() has been introduced in symfony/console:3.4, this should not happen. Perhaps a cache issue after upgrading?

@johmanx10

This comment has been minimized.

Show comment
Hide comment
@johmanx10

johmanx10 Dec 1, 2017

@chalasr I have manually removed all cache, as well as through the cache clear command, several times. That does not solve the issue.

Here is a subset of the results of composer show:

image

I'm masking proprietary packages for obvious reasons.

johmanx10 commented Dec 1, 2017

@chalasr I have manually removed all cache, as well as through the cache clear command, several times. That does not solve the issue.

Here is a subset of the results of composer show:

image

I'm masking proprietary packages for obvious reasons.

@johmanx10

This comment has been minimized.

Show comment
Hide comment
@johmanx10

johmanx10 Dec 1, 2017

@chalasr I can also reproduce this error in all our CI environments, where a fresh installation happens each time.

johmanx10 commented Dec 1, 2017

@chalasr I can also reproduce this error in all our CI environments, where a fresh installation happens each time.

@chalasr

This comment has been minimized.

Show comment
Hide comment
@chalasr

chalasr Dec 1, 2017

Contributor

@johmanx10 Can you please give me the minimal steps to reproduce, or give me a link to a failing public CI?

Contributor

chalasr commented Dec 1, 2017

@johmanx10 Can you please give me the minimal steps to reproduce, or give me a link to a failing public CI?

@johmanx10

This comment has been minimized.

Show comment
Hide comment
@johmanx10

johmanx10 Dec 1, 2017

@chalasr I cannot give you a link to a CI, because it's private. However, you can reproduce this as follows:

  1. Install a project with symfony/symfony:3.4
  2. Install DoctrineCacheBundle or any bundle that registers commands using DI tag console.command, but does not use the command attribute for the tag.
  3. Clear cache

johmanx10 commented Dec 1, 2017

@chalasr I cannot give you a link to a CI, because it's private. However, you can reproduce this as follows:

  1. Install a project with symfony/symfony:3.4
  2. Install DoctrineCacheBundle or any bundle that registers commands using DI tag console.command, but does not use the command attribute for the tag.
  3. Clear cache
@chalasr

This comment has been minimized.

Show comment
Hide comment
@chalasr

chalasr Dec 1, 2017

Contributor

@johmanx10 Still no issue on my side:

symfony new console-bug 3.4
composer require doctrine/doctrine-cache-bundle
# register the bundle in kernel
bin/console cache:clear
# runs fine

I can even run the doctrine:cache commands without issue.
Your error says Undefined method Doctrine\Bundle\DoctrineCacheBundle\Command\ContainsCommand::getDefaultName(), but this class extends the symfony/console Command class where the method does exist in 3.4.

Are you sure you that your setup doesn't replace the symfony Command class somehow?
Can you check that the method exists in your project vendors?

Contributor

chalasr commented Dec 1, 2017

@johmanx10 Still no issue on my side:

symfony new console-bug 3.4
composer require doctrine/doctrine-cache-bundle
# register the bundle in kernel
bin/console cache:clear
# runs fine

I can even run the doctrine:cache commands without issue.
Your error says Undefined method Doctrine\Bundle\DoctrineCacheBundle\Command\ContainsCommand::getDefaultName(), but this class extends the symfony/console Command class where the method does exist in 3.4.

Are you sure you that your setup doesn't replace the symfony Command class somehow?
Can you check that the method exists in your project vendors?

@johmanx10

This comment has been minimized.

Show comment
Hide comment
@johmanx10

johmanx10 Dec 1, 2017

@chalasr I have figured out why this error occurred locally. The cache clear was running as part of a Composer post install command. It has already loaded in the somewhat older Symfony console component from within the Composer PHAR. This is an issue with the private CI as well. After I have updated my local installation of Composer, it shifts to another error from within the composer.phar.

I believe this issue should be resolved as could not reproduce.

johmanx10 commented Dec 1, 2017

@chalasr I have figured out why this error occurred locally. The cache clear was running as part of a Composer post install command. It has already loaded in the somewhat older Symfony console component from within the Composer PHAR. This is an issue with the private CI as well. After I have updated my local installation of Composer, it shifts to another error from within the composer.phar.

I believe this issue should be resolved as could not reproduce.

@johmanx10 johmanx10 closed this Dec 1, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment