diff --git a/typo3/sysext/core/Classes/Console/CommandRegistry.php b/typo3/sysext/core/Classes/Console/CommandRegistry.php index 969a1be4f09ee9599d317d9206124a2dd94d9159..a82a32acb7879d29aa8d00344bc6564062ab701c 100644 --- a/typo3/sysext/core/Classes/Console/CommandRegistry.php +++ b/typo3/sysext/core/Classes/Console/CommandRegistry.php @@ -112,7 +112,7 @@ class CommandRegistry implements CommandLoaderInterface, \IteratorAggregate, Sin $this->populateCommandsFromPackages(); foreach ($this->commands as $commandName => $command) { if (is_string($command)) { - $command = $this->getInstance($command, $commandName); + $command = $this->getInstance($command); } yield $commandName => $command; } @@ -129,7 +129,7 @@ class CommandRegistry implements CommandLoaderInterface, \IteratorAggregate, Sin foreach ($this->commands as $commandName => $command) { if ($this->commandConfigurations[$commandName]['schedulable'] ?? true) { if (is_string($command)) { - $command = $this->getInstance($command, $commandName); + $command = $this->getInstance($command); } yield $commandName => $command; } @@ -171,7 +171,7 @@ class CommandRegistry implements CommandLoaderInterface, \IteratorAggregate, Sin $command = $this->commands[$identifier] ?? null; if (is_string($command)) { - $command = $this->getInstance($command, $identifier); + $command = $this->getInstance($command); } return $command; @@ -218,7 +218,7 @@ class CommandRegistry implements CommandLoaderInterface, \IteratorAggregate, Sin if (array_key_exists($commandName, $this->lazyCommandConfigurations)) { // Lazy (DI managed) commands override classic commands from Configuration/Commands.php // Skip this case to allow extensions to provide commands via DI config and to allow - // TYPO3 v9 backwards compatibile confguration via Configuration/Commands.php. + // TYPO3 v9 backwards compatible configuration via Configuration/Commands.php. // Note: Also the deprecation error is skipped on-demand as the extension has been // adapted and the configuration will be ignored as of TYPO3 v11. continue; @@ -242,26 +242,18 @@ class CommandRegistry implements CommandLoaderInterface, \IteratorAggregate, Sin } } - protected function getInstance(string $class, string $commandName): Command + protected function getInstance(string $class): Command { - $command = $this->container->get($class); - - if ($command instanceof Command) { - $command->setName($commandName); - return $command; - } - - throw new \InvalidArgumentException('Registered console command class ' . get_class($command) . ' does not inherit from ' . Command::class, 1567966448); + return $this->container->get($class); } /** * @internal */ - public function addLazyCommand(string $commandName, string $serviceName, bool $alias = false, bool $schedulable = true): void + public function addLazyCommand(string $commandName, string $serviceName, bool $schedulable = true): void { $this->lazyCommandConfigurations[$commandName] = [ 'class' => $serviceName, - 'alias' => $alias, 'schedulable' => $schedulable, ]; } diff --git a/typo3/sysext/core/Classes/DependencyInjection/ConsoleCommandPass.php b/typo3/sysext/core/Classes/DependencyInjection/ConsoleCommandPass.php index f35cc5cd9d4cf3fe6f2b1289557ae8c886fd20c7..75351ddbe75fbe57905b0938359a71c835ad2d43 100644 --- a/typo3/sysext/core/Classes/DependencyInjection/ConsoleCommandPass.php +++ b/typo3/sysext/core/Classes/DependencyInjection/ConsoleCommandPass.php @@ -47,20 +47,29 @@ final class ConsoleCommandPass implements CompilerPassInterface return; } - $unorderedEventListeners = []; foreach ($container->findTaggedServiceIds($this->tagName) as $serviceName => $tags) { - $container->findDefinition($serviceName)->setPublic(true); + $commandServiceDefinition = $container->findDefinition($serviceName)->setPublic(true); + $commandName = null; + $aliases = []; foreach ($tags as $attributes) { if (!isset($attributes['command'])) { continue; } - $commandRegistryDefinition->addMethodCall('addLazyCommand', [ $attributes['command'], $serviceName, - (bool)($attributes['alias'] ?? false), (bool)($attributes['schedulable'] ?? true) ]); + $isAlias = isset($commandName) || ($attributes['alias'] ?? false); + if (!$isAlias) { + $commandName = $attributes['command']; + } else { + $aliases[] = $attributes['command']; + } + } + $commandServiceDefinition->addMethodCall('setName', [$commandName]); + if ($aliases) { + $commandServiceDefinition->addMethodCall('setAliases', [$aliases]); } } } diff --git a/typo3/sysext/install/Classes/ServiceProvider.php b/typo3/sysext/install/Classes/ServiceProvider.php index a1874db01e6f8c9cac491a14e8193300683e9d3b..5de3b358796e5af661faf91a417fa16242e46fc2 100644 --- a/typo3/sysext/install/Classes/ServiceProvider.php +++ b/typo3/sysext/install/Classes/ServiceProvider.php @@ -115,17 +115,17 @@ class ServiceProvider extends AbstractServiceProvider public static function getLanguagePackCommand(ContainerInterface $container): Command\LanguagePackCommand { - return new Command\LanguagePackCommand; + return new Command\LanguagePackCommand('language:update'); } public static function getUpgradeWizardRunCommand(ContainerInterface $container): Command\UpgradeWizardRunCommand { - return new Command\UpgradeWizardRunCommand; + return new Command\UpgradeWizardRunCommand('upgrade:run'); } public static function getUpgradeWizardListCommand(ContainerInterface $container): Command\UpgradeWizardListCommand { - return new Command\UpgradeWizardListCommand; + return new Command\UpgradeWizardListCommand('upgrade:list'); } public static function configureCommands(ContainerInterface $container, CommandRegistry $commandRegistry): CommandRegistry