diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-20 14:24:48 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-20 14:24:48 +0900 |
| commit | c854041bfca63f39ace6f0c01892e81889f90bb3 (patch) | |
| tree | 0273d6bed22c0009ea026f927b46805eb8ac0e47 /crates | |
| parent | e77a37c5447a4d122629ef8fbc9bef309668aa89 (diff) | |
| download | php-shirabe-c854041bfca63f39ace6f0c01892e81889f90bb3.tar.gz php-shirabe-c854041bfca63f39ace6f0c01892e81889f90bb3.tar.zst php-shirabe-c854041bfca63f39ace6f0c01892e81889f90bb3.zip | |
fix(global-command): call base_run to stop run() infinite recursion
GlobalCommand::run fell back to self.run when given fewer than two
args, recursing forever and overflowing the stack. PHP calls
parent::run there. Add Command::base_run holding the base run body so
the override can delegate to it, matching PHP's parent::run.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates')
| -rw-r--r-- | crates/shirabe-external-packages/src/symfony/console/command/command.rs | 12 | ||||
| -rw-r--r-- | crates/shirabe/src/command/global_command.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/tests/cli.rs | 2 |
3 files changed, 14 insertions, 2 deletions
diff --git a/crates/shirabe-external-packages/src/symfony/console/command/command.rs b/crates/shirabe-external-packages/src/symfony/console/command/command.rs index e737b58..2d94ad2 100644 --- a/crates/shirabe-external-packages/src/symfony/console/command/command.rs +++ b/crates/shirabe-external-packages/src/symfony/console/command/command.rs @@ -394,6 +394,18 @@ pub trait Command: std::fmt::Debug + shirabe_php_shim::AsAny { input: Rc<RefCell<dyn InputInterface>>, output: Rc<RefCell<dyn OutputInterface>>, ) -> anyhow::Result<i64> { + self.base_run(input, output) + } + + /// The base-class (`Command`) body of `run`, as PHP's `Command::run`. Proxy commands such as + /// `GlobalCommand` override `run` but still call `base_run` to delegate to the base behavior, + /// matching PHP's `parent::run($input, $output)`. It must not be overridden, or the late + /// binding of `initialize`/`interact`/`execute` to the concrete command breaks. + fn base_run( + &mut self, + input: Rc<RefCell<dyn InputInterface>>, + output: Rc<RefCell<dyn OutputInterface>>, + ) -> anyhow::Result<i64> { // add the application arguments and options self.merge_application_definition(true); diff --git a/crates/shirabe/src/command/global_command.rs b/crates/shirabe/src/command/global_command.rs index 941315b..0645b3a 100644 --- a/crates/shirabe/src/command/global_command.rs +++ b/crates/shirabe/src/command/global_command.rs @@ -180,7 +180,7 @@ impl Command for GlobalCommand { } if args.len() < 2 { - return self.run(input, output); + return self.base_run(input, output); } let sub_input = self.prepare_subcommand_input(input, false)?; diff --git a/crates/shirabe/tests/cli.rs b/crates/shirabe/tests/cli.rs index 549e5a3..196e93b 100644 --- a/crates/shirabe/tests/cli.rs +++ b/crates/shirabe/tests/cli.rs @@ -149,7 +149,7 @@ run_no_panic_tests! { run_exec => "exec", #[ignore = "currently panics"] run_fund => "fund", - #[ignore = "stack overflow aborts the process (uncatchable)"] + #[ignore = "currently panics"] run_global => "global", #[ignore = "currently panics"] run_init => "init", |
