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

[BUGFIX] Fail upgrade when incompatible extensions are found #819

Merged
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
15 changes: 15 additions & 0 deletions Classes/Console/Command/UpgradeCommandController.php
Expand Up @@ -81,6 +81,7 @@ public function checkExtensionConstraintsCommand(array $extensionKeys = [], $typ
*/
public function listCommand($all = false)
{
$this->ensureExtensionCompatibility();
$verbose = $this->output->getSymfonyConsoleOutput()->isVerbose();
$messages = [];
$wizards = $this->upgradeHandling->executeInSubProcess('listWizards', [], $messages);
Expand Down Expand Up @@ -108,6 +109,7 @@ public function listCommand($all = false)
*/
public function wizardCommand($identifier, array $arguments = [], $force = false)
{
$this->ensureExtensionCompatibility();
$messages = [];
$result = $this->upgradeHandling->executeInSubProcess('executeWizard', [$identifier, $arguments, $force], $messages);
(new UpgradeWizardResultRenderer())->render([$identifier => $result], $this->output);
Expand All @@ -124,6 +126,7 @@ public function wizardCommand($identifier, array $arguments = [], $force = false
*/
public function allCommand(array $arguments = [])
{
$this->ensureExtensionCompatibility();
$verbose = $this->output->getSymfonyConsoleOutput()->isVerbose();
$this->outputLine(PHP_EOL . '<i>Initiating TYPO3 upgrade</i>' . PHP_EOL);

Expand All @@ -143,6 +146,18 @@ public function allCommand(array $arguments = [])
}
}

private function ensureExtensionCompatibility()
{
$messages = $this->upgradeHandling->ensureExtensionCompatibility();
if (!empty($messages)) {
$this->outputLine('<error>Incompatible extensions found, aborting.</error>');
foreach ($messages as $message) {
$this->outputLine($message);
}
$this->quit(1);
}
}

/**
* This is where the hard work happens in a fully bootstrapped TYPO3
* It will be called as sub process
Expand Down
57 changes: 27 additions & 30 deletions Classes/Console/Install/Upgrade/UpgradeHandling.php
Expand Up @@ -159,9 +159,7 @@ public function executeAll(array $arguments, ConsoleOutput $consoleOutput, array
}
}
}
$wizardMessages = [];
$results[$shortIdentifier] = $this->executeInSubProcess('executeWizard', [$shortIdentifier, $arguments], $wizardMessages);
$messages = array_merge($messages, $wizardMessages);
$results[$shortIdentifier] = $this->executeInSubProcess('executeWizard', [$shortIdentifier, $arguments]);
}
}

Expand Down Expand Up @@ -222,15 +220,14 @@ public function findIncompatible(): array
*
* @param string $command
* @param array $arguments
* @param array &$messages
* @throws FailedSubProcessCommandException
* @throws \UnexpectedValueException
* @throws \RuntimeException
* @return mixed
*/
public function executeInSubProcess($command, array $arguments = [], array &$messages = [])
public function executeInSubProcess($command, array $arguments = [])
{
$messages = $this->ensureUpgradeIsPossible();
$this->ensureUpgradeIsPossible();

return @unserialize($this->commandDispatcher->executeCommand('upgrade:subprocess', [$command, serialize($arguments)]));
}
Expand All @@ -239,38 +236,38 @@ public function executeInSubProcess($command, array $arguments = [], array &$mes
* @throws FailedSubProcessCommandException
* @throws \UnexpectedValueException
* @throws \RuntimeException
* @return string[]
*/
private function ensureUpgradeIsPossible()
{
$messages = [];
if (!$this->initialUpgradeDone
&& (
!$this->configurationService->hasLocal('EXTCONF/helhum-typo3-console/initialUpgradeDone')
|| TYPO3_branch !== $this->configurationService->getLocal('EXTCONF/helhum-typo3-console/initialUpgradeDone')
)
) {
$this->initialUpgradeDone = true;
$this->configurationService->setLocal('EXTCONF/helhum-typo3-console/initialUpgradeDone', TYPO3_branch, 'string');
$this->commandDispatcher->executeCommand('install:fixfolderstructure');
$messages = $this->ensureExtensionCompatibility();
$this->silentConfigurationUpgrade->executeSilentConfigurationUpgradesIfNeeded();
// TODO: Check what we can do here to get TYPO3 9 support for this feature
if (class_exists(DatabaseCharsetUpdate::class)) {
$this->commandDispatcher->executeCommand('upgrade:wizard', [DatabaseCharsetUpdate::class]);
}
$this->commandDispatcher->executeCommand('cache:flush');
$this->commandDispatcher->executeCommand('database:updateschema');
if ($this->isInitialUpgradeDone()) {
return;
}
$this->initialUpgradeDone = true;
$this->configurationService->setLocal('EXTCONF/helhum-typo3-console/initialUpgradeDone', TYPO3_branch, 'string');
$this->commandDispatcher->executeCommand('install:fixfolderstructure');
$this->silentConfigurationUpgrade->executeSilentConfigurationUpgradesIfNeeded();
// TODO: Check what we can do here to get TYPO3 9 support for this feature
if (class_exists(DatabaseCharsetUpdate::class)) {
$this->commandDispatcher->executeCommand('upgrade:wizard', [DatabaseCharsetUpdate::class]);
}
$this->commandDispatcher->executeCommand('cache:flush');
$this->commandDispatcher->executeCommand('database:updateschema');
}

return $messages;
private function isInitialUpgradeDone(): bool
{
return $this->initialUpgradeDone
|| (
$this->configurationService->hasLocal('EXTCONF/helhum-typo3-console/initialUpgradeDone')
&& $this->configurationService->getLocal('EXTCONF/helhum-typo3-console/initialUpgradeDone') === TYPO3_branch
);
}

/**
* @return string[]
*/
private function ensureExtensionCompatibility()
public function ensureExtensionCompatibility(): array
{
if ($this->isInitialUpgradeDone()) {
return [];
}
$messages = [];
$failedPackageMessages = $this->matchAllExtensionConstraints(TYPO3_version);
foreach ($failedPackageMessages as $extensionKey => $constraintMessage) {
Expand Down