-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[FrameworkBundle] do not re-register commands each time a Console\Application is run #8242
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
tomdmaguire
wants to merge
2
commits into
symfony:master
from
tomdmaguire:console_reregister_commands_fix
Closed
[FrameworkBundle] do not re-register commands each time a Console\Application is run #8242
tomdmaguire
wants to merge
2
commits into
symfony:master
from
tomdmaguire:console_reregister_commands_fix
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -65,7 +66,9 @@ public function getKernel() | |||
*/ | |||
public function doRun(InputInterface $input, OutputInterface $output) | |||
{ | |||
$this->registerCommands(); | |||
if(!$this->commandsRegistered){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace after the if
.
$this->registerCommands(); | ||
if (!$this->commandsRegistered) { | ||
$this->registerCommands(); | ||
} | ||
|
||
$this->setDispatcher($this->kernel->getContainer()->get('event_dispatcher')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe the dispatcher may not need to be set each time as well?
fabpot
added a commit
that referenced
this pull request
Jun 13, 2013
This PR was submitted for the master branch but it was merged into the 2.2 branch instead (closes #8242). Discussion ---------- [FrameworkBundle] do not re-register commands each time a Console\Application is run | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | I have been experimenting with using the Symfony console application inside of a React event loop which works quite well. In this scenario, I re-use an instances of a Console\Application to run multiple tasks. This works well apart from unnecessarily reloading the command classes from all included bundles each time doRun() is called (https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/Console/Application.php#L68). This can also lead to running out of file descriptors under heavy load as bootstrap.php.cache uses a RecursiveDirectoryIterator to load the command. Commits ------- 1983fc3 [FrameworkBundle] do not re-register commands each time a Console\Application is run
fabpot
added a commit
that referenced
this pull request
Jun 13, 2013
fabpot
added a commit
that referenced
this pull request
Jun 13, 2013
* 2.2: Throw exception if value is passed to VALUE_NONE input, long syntax fixed date type format pattern regex [FrameworkBundle] tweaked previous merge (refs #8242) do not re-register commands each time a Console\Application is run [Process] moved env check to the Process class (refs #8227) fix issue where $_ENV contains array vals [DomCrawler] Fix handling file:// without a host [Form] corrected interface bind() method defined against in deprecation notice [Finder] Fix SplFileInfo::getContents isn't working with ssh2 protocol Conflicts: src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php src/Symfony/Component/DomCrawler/Link.php src/Symfony/Component/Form/Form.php
fabpot
added a commit
that referenced
this pull request
Jun 23, 2013
* 2.3: (33 commits) [Form] fixed INF usage which does not work on Solaris (closes #8246) Fix grammar Removed PHP 5.5 from the allowed failures. [Intl] Fixed tests failing on PHP 5.5 bumped Symfony version to 2.2.4 updated VERSION for 2.2.3 update CONTRIBUTORS for 2.2.3 updated CHANGELOG for 2.2.3 [DependencyInjection] Replaced try/catch block with an @ExpectedException annotation in a test. [CssSelector] tweaked README file (closes #8287) added a node about HTML extension in readme [Console] Fixed the table rendering with multi-byte strings. Feature/fix unit tests [Process] Disable exception on stream_select timeout [HttpFoundation] fixed issue with session_regenerate_id (closes #7380) [DomCrawler] added a note about the default charset Throw exception if value is passed to VALUE_NONE input, long syntax fixed date type format pattern regex [Security] fixed usage of the salt for the bcrypt encoder (refs #8210) [FrameworkBundle] tweaked previous merge (refs #8242) ... Conflicts: src/Symfony/Component/HttpKernel/Kernel.php
fabpot
added a commit
that referenced
this pull request
Jul 29, 2013
This PR was merged into the master branch. Discussion ---------- [FrameworkBundle] fixed regression where the command might have the wrong container if the application is reused several times | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a This fixes a regression introduced in #8242. Before this PR, the commands were always getting the current container registered in the kernel. But as the commands are now registered only once, if the container changes, the commands were not aware of this change. That happens quite frequently in functional tests where the Kernel is booted and shutdown several times in the same process. Commits ------- 1bd45b3 [FrameworkBundle] fixed regression where the command might have the wrong container if the application is reused several times
ostrolucky
pushed a commit
to ostrolucky/symfony
that referenced
this pull request
Mar 25, 2018
* 2.3: (33 commits) [Form] fixed INF usage which does not work on Solaris (closes symfony#8246) Fix grammar Removed PHP 5.5 from the allowed failures. [Intl] Fixed tests failing on PHP 5.5 bumped Symfony version to 2.2.4 updated VERSION for 2.2.3 update CONTRIBUTORS for 2.2.3 updated CHANGELOG for 2.2.3 [DependencyInjection] Replaced try/catch block with an @ExpectedException annotation in a test. [CssSelector] tweaked README file (closes symfony#8287) added a node about HTML extension in readme [Console] Fixed the table rendering with multi-byte strings. Feature/fix unit tests [Process] Disable exception on stream_select timeout [HttpFoundation] fixed issue with session_regenerate_id (closes symfony#7380) [DomCrawler] added a note about the default charset Throw exception if value is passed to VALUE_NONE input, long syntax fixed date type format pattern regex [Security] fixed usage of the salt for the bcrypt encoder (refs symfony#8210) [FrameworkBundle] tweaked previous merge (refs symfony#8242) ... Conflicts: src/Symfony/Component/HttpKernel/Kernel.php
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I have been experimenting with using the Symfony console application inside of a React event loop which works quite well.
In this scenario, I re-use an instances of a Console\Application to run multiple tasks. This works well apart from unnecessarily reloading the command classes from all included bundles each time doRun() is called (https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/Console/Application.php#L68). This can also lead to running out of file descriptors under heavy load as bootstrap.php.cache uses a RecursiveDirectoryIterator to load the command.