8000 Configure is called for all commands when potentially/arguably only the description is needed. · Issue #21781 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
Configure is called for all commands when potentially/arguably only the description is needed. #21781
Closed
@rquadling

Description

@rquadling
Q A
Bug report? no
Feature request? yes
BC Break report? no
RFC? yes/no
Symfony version 2.8.17

If you have several \Symfony\Component\Console\Command\Commands, all registered against a \Symfony\Component\Console\Application, when running the application, all the \Symfony\Component\Console\Command\Command::configure() methods are called, even when a single command is chosen.

This is normally fine and I suspect this presents little or no problems at all.

But, as a consequence, when only the command's description is required (when running the application without any command) or no configuration required at all (when running the application with another command), the entire command is configured every single time. If that configuration requires access to external sources to provide options, or default values, etc. then this happens unnecessarily. Added to that, if there is an error in this external data retrieval, the exception is generated for what seems a completely unrelated command.

It would be nice to be able to be a bit more circumspect with what code is executed.

From that, I think there are 3 types of usage:

  1. When running the application without a command, only the description is required.
  2. When running the application with a different command, don't configure anything at all.
  3. When running the application with this command, configure it as things currently are.

One area where I'm not sure of is the interaction between command A running command B. I'm thinking this should match type 3 above.

If this is an issue for anyone, then I'm happy to work on it and build a PR, but would appreciate some direction on a good implementation. Ideally not too intrusive and something that is backward compatible.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0