jonaswouters / XhprofBundle

XHProf bundle for Symfony 2
210 stars 49 forks source link

The "--xhprof" option does not exist #82

Closed tautrimas closed 8 years ago

tautrimas commented 8 years ago

Hello,

I did not notice when, but such bug appeared.

Our configuration:

jns_xhprof:
    enabled: true
    command: option
    command_option_name: xhprof

Upon clearing caches this always happens no matter if we set the option or don't:

  The "--xhprof" option does not exist.

...
 Jns\Bundle\XhprofBundle\EventListener\CommandListener->isProfileOption() at /var/www_match/vendor/jns/xhprof-bundle/EventListener/CommandListener.php:125
...

Maybe it was impacted by Symfony 2.8 upgrade?

I managed to workaround this by using new Symfony 2.8 functionality and simplifying isProfileOption method:

private function isProfileOption(ConsoleCommandEvent $event)
    {
        $definition = $event->getCommand()->getDefinition();
        $input = $event->getInput();

        $definition->addOption(new InputOption($this->optionName, null, InputOption::VALUE_NONE, '<info>JnsXhprofBundle</info>: Whether to profile this command with xhprof', null));
        $input->bind($definition);
    }
jonaswouters commented 8 years ago

Should be fixed in #83