Skip to content
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

[TASK] Migrate upgrade commands #1113

Merged
merged 1 commit into from Feb 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions Classes/Console/Command/Upgrade/UpgradeListCommand.php
Expand Up @@ -21,9 +21,15 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use TYPO3\CMS\Core\Core\BootService;

class UpgradeListCommand extends Command
{
public function __construct(private readonly BootService $bootService)
{
parent::__construct('upgrade:list');
}

protected function configure()
{
$this->setDescription('List upgrade wizards');
Expand All @@ -37,6 +43,8 @@ protected function configure()

protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->bootService->loadExtLocalconfDatabaseAndExtTables();

$upgradeHandling = new UpgradeHandling();
if (!$upgradeHandling->isUpgradePrepared()) {
$upgradeHandling->prepareUpgrade();
Expand Down
21 changes: 21 additions & 0 deletions Classes/Console/Command/Upgrade/UpgradeRunCommand.php
Expand Up @@ -25,6 +25,7 @@
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ChoiceQuestion;
use Symfony\Component\Console\Style\SymfonyStyle;
use TYPO3\CMS\Core\Core\BootService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Install\Service\UpgradeWizardsService;
use TYPO3\CMS\Install\Updates\DatabaseRowsUpdateWizard;
Expand All @@ -33,6 +34,13 @@ class UpgradeRunCommand extends Command
{
private const allWizardsOrConfirmations = 'all';

private bool $booted = false;

public function __construct(private readonly BootService $bootService)
{
parent::__construct('upgrade:run');
}

/**
* @var UpgradeHandling
*/
Expand Down Expand Up @@ -97,6 +105,8 @@ protected function configure()

protected function interact(InputInterface $input, OutputInterface $output)
{
$this->ensureBooted();

$this->upgradeHandling = new UpgradeHandling();
if (empty($input->getArgument('wizardIdentifiers'))) {
$scheduledWizards = $this->upgradeHandling->listWizards()['scheduled'];
Expand Down Expand Up @@ -125,6 +135,8 @@ protected function interact(InputInterface $input, OutputInterface $output)

protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->ensureBooted();

$this->upgradeHandling = $this->upgradeHandling ?? new UpgradeHandling();
if (!$this->upgradeHandling->isUpgradePrepared()) {
$this->upgradeHandling->prepareUpgrade();
Expand All @@ -144,6 +156,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return 0;
}

private function ensureBooted(): void
{
if ($this->booted) {
return;
}
$this->bootService->loadExtLocalconfDatabaseAndExtTables();
$this->booted = true;
}

private function unpackArguments(InputInterface $input): array
{
$wizardsToExecute = $input->getArgument('wizardIdentifiers');
Expand Down
16 changes: 16 additions & 0 deletions Classes/Console/ServiceProvider.php
Expand Up @@ -19,13 +19,17 @@
use Helhum\Typo3Console\Command\Install\InstallSetupCommand;
use Helhum\Typo3Console\Command\InstallTool\LockInstallToolCommand;
use Helhum\Typo3Console\Command\InstallTool\UnlockInstallToolCommand;
use Helhum\Typo3Console\Command\Upgrade\UpgradeListCommand;
use Helhum\Typo3Console\Command\Upgrade\UpgradeRunCommand;
use Helhum\Typo3Console\Database\Configuration\ConnectionConfiguration;
use Psr\Container\ContainerInterface;
use TYPO3\CMS\Core\Configuration\ConfigurationManager;
use TYPO3\CMS\Core\Console\CommandRegistry;
use TYPO3\CMS\Core\Core\BootService;
use TYPO3\CMS\Core\Core\Bootstrap;
use TYPO3\CMS\Core\Package\AbstractServiceProvider;
use TYPO3\CMS\Install\Command\UpgradeWizardListCommand;
use TYPO3\CMS\Install\Command\UpgradeWizardRunCommand;

class ServiceProvider extends AbstractServiceProvider
{
Expand Down Expand Up @@ -54,6 +58,8 @@ public function getFactories(): array
InstallActionNeedsExecutionCommand::class => [ static::class, 'getInstallActionNeedsExecutionCommand' ],
LockInstallToolCommand::class => [ static::class, 'getLockInstallToolCommand' ],
UnlockInstallToolCommand::class => [ static::class, 'getUnlockInstallToolCommand' ],
UpgradeWizardListCommand::class => [ static::class, 'getUpgradeListCommand' ],
UpgradeWizardRunCommand::class => [ static::class, 'getUpgradeRunCommand' ],
];
}

Expand Down Expand Up @@ -157,6 +163,16 @@ public static function getUnlockInstallToolCommand(): UnlockInstallToolCommand
return new UnlockInstallToolCommand('install:unlock');
}

public static function getUpgradeListCommand(ContainerInterface $container): UpgradeListCommand
{
return new UpgradeListCommand($container->get(BootService::class));
}

public static function getUpgradeRunCommand(ContainerInterface $container): UpgradeRunCommand
{
return new UpgradeRunCommand($container->get(BootService::class));
}

public static function configureCommands(ContainerInterface $container, CommandRegistry $commandRegistry): CommandRegistry
{
$commandRegistry->addLazyCommand('configuration:remove', ConfigurationRemoveCommand::class, 'Remove configuration value');
Expand Down
21 changes: 0 additions & 21 deletions Configuration/Commands.php

This file was deleted.