-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
[Console][FrameworkBundle] --profile
option might not be set on every command
#52433
Comments
Hello, I tried to reproduce the error, but the |
Same issue on 6.4 BETA 2
To give more details: We are overriding We have something like that: final class Application extends SymfonyFrameworkApplication
{
public function __construct(KernelInterface $kernel)
{
parent::__construct($kernel);
$inputDefinition = $this->getDefaultInputDefinition();
$inputDefinition->addOptions([
new InputOption('--env', null, InputOption::VALUE_REQUIRED, 'The Environment name.', $kernel->getEnvironment()),
new InputOption('--no-debug', null, InputOption::VALUE_NONE, 'Switches off debug mode.'),
]);
$this->setDefinition($inputDefinition);
}
} and the |
…r console commands (keulinho) This PR was merged into the 6.4 branch. Discussion ---------- [Console][FrameworkBundle] Fix missing `profile` option for console commands | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Issues | Fix #52433 | License | MIT Commits ------- 0e0848b Fix missing `profile` option for console commands
…r console commands (keulinho) This PR was merged into the 6.4 branch. Discussion ---------- [Console][FrameworkBundle] Fix missing `profile` option for console commands | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Issues | Fix symfony/symfony#52433 | License | MIT Commits ------- 0e0848bc27 Fix missing `profile` option for console commands
Symfony version(s) affected
6.4
Description
With the new command profiling feature, a event listener was added that grabs the
profile
option from the command inputs:https://github.com/symfony/symfony/blob/6.4/src/Symfony/Bundle/FrameworkBundle/EventListener/ConsoleProfilerListener.php#L62
Normaly that option is added to every command over the Application: https://github.com/symfony/symfony/blob/6.4/src/Symfony/Bundle/FrameworkBundle/Console/Application.php#L47
However not every command is executed over the Application class, e.g. during unit tests with the
CommandTester
or by just dispatching theConsoleCommandEvent
directly.In those cases the following error is thrown:
How to reproduce
Use the command tester to test a manually created command:
Note: this differs from how the command tester is documented: https://symfony.com/doc/current/console.html#testing-commands
As there the command is fetched from the application, however, to properly unit test commands without having the whole application booted up, I think the above code is valid for testing commands and should be supported.
Possible Solution
Check if the option exists before accessing it -> PR incoming
Additional Context
No response
The text was updated successfully, but these errors were encountered: