first commit

This commit is contained in:
salam committed 2026-10-19 08:18:39 +02:00
commit 1218dd1517
12716 files changed
+989233

No files matched your search

@@ -0,0 +1,105 @@
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Install\Command;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\NullOutput;
use Symfony\Component\Console\Output\OutputInterface;
use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Install\Service\LanguagePackService;
/**
* Core function for updating language packs
*/
class LanguagePackCommand extends Command
{
/**
* Configure the command by defining the name, options and arguments
*/
protected function configure()
{
$this->setAliases(['lang:language:update']);
$this->setDescription('Update the language files of all activated extensions')
->addArgument(
'locales',
InputArgument::IS_ARRAY | InputArgument::OPTIONAL,
'Provide iso codes separated by space to update only selected language packs. Example `bin/typo3 language:update de ja`.'
);
}
/**
* Update language packs of all active languages for all active extensions
*
* @param InputInterface $input
* @param OutputInterface $output
* @throws \InvalidArgumentException
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
if ($input->hasArgument('command') && substr_count($input->getArgument('command'), ':') === 2) {
$message = 'bin/typo3 lang:language:update is deprecated, use bin/typo3 language:update instead';
$output->writeln('<error>' . $message . '</error>');
trigger_error($message, E_USER_DEPRECATED);
}
$languagePackService = GeneralUtility::makeInstance(LanguagePackService::class);
try {
$isos = $input->getArgument('locales');
} catch (\Exception $e) {
$isos = [];
}
if (empty($isos)) {
$isos = $languagePackService->getActiveLanguages();
}
if ($output->isVerbose()) {
$output->writeln(sprintf(
'<info>Updating language packs of all activated extensions for locale(s) "%s"</info>',
implode('", "', $isos)
));
}
$extensions = $languagePackService->getExtensionLanguagePackDetails();
if (!$output->isVerbose()) {
$progressBarOutput = new NullOutput();
} else {
$progressBarOutput = $output;
}
$progressBar = new ProgressBar($progressBarOutput, count($isos) * count($extensions));
$languagePackService->updateMirrorBaseUrl();
foreach ($isos as $iso) {
foreach ($extensions as $extension) {
$languagePackService->languagePackDownload($extension['key'], $iso);
$progressBar->advance();
}
}
$languagePackService->setLastUpdatedIsoCode($isos);
$progressBar->finish();
// Flush language cache
GeneralUtility::makeInstance(CacheManager::class)->getCache('l10n')->flush();
return 0;
}
}
@@ -0,0 +1,150 @@
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Install\Command;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use TYPO3\CMS\Core\Authentication\CommandLineUserAuthentication;
use TYPO3\CMS\Core\Core\Bootstrap;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Install\Service\UpgradeWizardsService;
use TYPO3\CMS\Install\Updates\ChattyInterface;
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;
/**
* Upgrade wizard command for listing wizards
*
* @internal
*/
class UpgradeWizardListCommand extends Command
{
/**
* @var UpgradeWizardsService
*/
private $upgradeWizardsService;
/**
* @var OutputInterface|\Symfony\Component\Console\Style\StyleInterface
*/
private $output;
/**
* @var InputInterface
*/
private $input;
/**
* Bootstrap running of upgradeWizards
*/
protected function bootstrap(): void
{
Bootstrap::loadTypo3LoadedExtAndExtLocalconf(false);
Bootstrap::unsetReservedGlobalVariables();
Bootstrap::loadBaseTca(false);
Bootstrap::loadExtTables(false);
Bootstrap::initializeBackendUser(CommandLineUserAuthentication::class);
Bootstrap::initializeBackendAuthentication();
}
/**
* Configure the command by defining the name, options and arguments
*/
protected function configure()
{
$this->setDescription('List available upgrade wizards.')
->addOption(
'all',
'a',
InputOption::VALUE_NONE,
'Include wizards already done.'
);
}
/**
* List available upgrade wizards. If -all is given, already done wizards are listed, too.
*
* @param InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->output = new SymfonyStyle($input, $output);
$this->input = $input;
$this->bootstrap();
$this->upgradeWizardsService = new UpgradeWizardsService();
$result = 0;
$wizards = [];
$all = $input->getOption('all');
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'] as $identifier => $wizardToExecute) {
$upgradeWizard = $this->getWizard($wizardToExecute, $identifier, (bool)$all);
if ($upgradeWizard !== null) {
$wizardInfo = [
'identifier' => $upgradeWizard->getIdentifier(),
'title' => $upgradeWizard->getTitle(),
'description' => wordwrap($upgradeWizard->getDescription()),
];
if ($all === true) {
$wizardInfo['status'] = $this->upgradeWizardsService->isWizardDone($identifier) ? 'DONE' : 'AVAILABLE';
}
$wizards[] = $wizardInfo;
}
}
if (empty($wizards)) {
$this->output->success('No wizards available.');
} else {
if ($all === true) {
$this->output->table(['Identifier', 'Title', 'Description', 'Status'], $wizards);
} else {
$this->output->table(['Identifier', 'Title', 'Description'], $wizards);
}
}
return $result;
}
/**
* Get Wizard instance by class name and identifier
* Returns null if wizard is already done
*
* @param string $className
* @param string $identifier
* @param bool $all
* @return \TYPO3\CMS\Install\Updates\UpgradeWizardInterface|null
*/
protected function getWizard(string $className, string $identifier, $all = false): ?UpgradeWizardInterface
{
// already done
if (!$all && $this->upgradeWizardsService->isWizardDone($identifier)) {
return null;
}
$wizardInstance = GeneralUtility::makeInstance($className);
if ($wizardInstance instanceof ChattyInterface) {
$wizardInstance->setOutput($this->output);
}
if (!($wizardInstance instanceof UpgradeWizardInterface)) {
return null;
}
return !$all ? $wizardInstance->updateNecessary() ? $wizardInstance : null : $wizardInstance;
}
}
@@ -0,0 +1,289 @@
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Install\Command;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ConfirmationQuestion;
use Symfony\Component\Console\Style\SymfonyStyle;
use TYPO3\CMS\Core\Authentication\CommandLineUserAuthentication;
use TYPO3\CMS\Core\Core\Bootstrap;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Install\Service\UpgradeWizardsService;
use TYPO3\CMS\Install\Updates\ChattyInterface;
use TYPO3\CMS\Install\Updates\ConfirmableInterface;
use TYPO3\CMS\Install\Updates\PrerequisiteCollection;
use TYPO3\CMS\Install\Updates\RepeatableInterface;
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;
/**
* Upgrade wizard command for running wizards
*
* @internal
*/
class UpgradeWizardRunCommand extends Command
{
/**
* @var UpgradeWizardsService
*/
private $upgradeWizardsService;
/**
* @var OutputInterface|\Symfony\Component\Console\Style\StyleInterface
*/
private $output;
/**
* @var InputInterface
*/
private $input;
/**
* Bootstrap running of upgrade wizard,
* ensure database is utf-8
*/
protected function bootstrap(): void
{
Bootstrap::loadTypo3LoadedExtAndExtLocalconf(false);
Bootstrap::unsetReservedGlobalVariables();
Bootstrap::loadBaseTca(false);
Bootstrap::loadExtTables(false);
Bootstrap::initializeBackendUser(CommandLineUserAuthentication::class);
Bootstrap::initializeBackendAuthentication();
$this->upgradeWizardsService = new UpgradeWizardsService();
$this->upgradeWizardsService->isDatabaseCharsetUtf8() ?: $this->upgradeWizardsService->setDatabaseCharsetUtf8();
}
/**
* Configure the command by defining the name, options and arguments
*/
protected function configure()
{
$this->setDescription('Run upgrade wizard. Without arguments all available wizards will be run.')
->addArgument(
'wizardName',
InputArgument::OPTIONAL
)->setHelp(
'This command allows running upgrade wizards on CLI. To run a single wizard add the ' .
'identifier of the wizard as argument. The identifier of the wizard is the name it is ' .
'registered with in ext_localconf.'
);
}
/**
* Update language packs of all active languages for all active extensions
*
* @param InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->output = new SymfonyStyle($input, $output);
$this->input = $input;
$this->bootstrap();
$result = 0;
if ($input->getArgument('wizardName')) {
$wizardToExecute = $input->getArgument('wizardName');
if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'][$wizardToExecute])) {
$className = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'][$wizardToExecute];
$upgradeWizard = $this->getWizard($className, $wizardToExecute);
if ($upgradeWizard !== null) {
$prerequisitesFulfilled = $this->handlePrerequisites([$upgradeWizard]);
if ($prerequisitesFulfilled === true) {
$result = $this->runSingleWizard($upgradeWizard);
} else {
$result = 1;
}
}
} else {
$this->output->error('No such wizard: ' . $wizardToExecute);
$result = 1;
}
} else {
$result = $this->runAllWizards();
}
return $result;
}
/**
* Get Wizard instance by class name and identifier
* Returns null if wizard is already done
*
* @param $className
* @param $identifier
* @return \TYPO3\CMS\Install\Updates\UpgradeWizardInterface|null
*/
protected function getWizard(string $className, string $identifier): ?UpgradeWizardInterface
{
// already done
if ($this->upgradeWizardsService->isWizardDone($identifier)) {
return null;
}
$wizardInstance = GeneralUtility::makeInstance($className);
if ($wizardInstance instanceof ChattyInterface) {
$wizardInstance->setOutput($this->output);
}
if (!($wizardInstance instanceof UpgradeWizardInterface)) {
$this->output->writeln(
'Wizard ' .
$identifier .
' needs to be manually run from the install tool, as it does not implement ' .
UpgradeWizardInterface::class
);
return null;
}
if ($wizardInstance->updateNecessary()) {
return $wizardInstance;
}
if ($wizardInstance instanceof RepeatableInterface) {
$this->output->note('Wizard ' . $identifier . ' does not need to make changes.');
} else {
$this->output->note('Wizard ' . $identifier . ' does not need to make changes. Marking wizard as done.');
$this->upgradeWizardsService->markWizardAsDone($identifier);
}
return null;
}
/**
* Handles prerequisites of update wizards, allows a more flexible definition and declaration of dependencies
* Currently implemented prerequisites include "database needs to be up-to-date" and "referenceIndex needs to be up-
* to-date"
* At the moment the install tool automatically displays the database updates when necessary but can't do more
* prerequisites
*
* @param UpgradeWizardInterface[] $instances
* @return bool
*/
protected function handlePrerequisites(array $instances): bool
{
$prerequisites = GeneralUtility::makeInstance(PrerequisiteCollection::class);
foreach ($instances as $instance) {
foreach ($instance->getPrerequisites() as $prerequisite) {
$prerequisites->add($prerequisite);
}
}
$result = true;
foreach ($prerequisites as $prerequisite) {
if ($prerequisite instanceof ChattyInterface) {
$prerequisite->setOutput($this->output);
}
if (!$prerequisite->isFulfilled()) {
$this->output->writeln('Prerequisite "' . $prerequisite->getTitle() . '" not fulfilled, will ensure.');
$result = $prerequisite->ensure();
if ($result === false) {
$this->output->error(
'<error>Error running ' .
$prerequisite->getTitle() .
'. Please ensure this prerequisite manually and try again.</error>'
);
break;
}
} else {
$this->output->writeln('Prerequisite "' . $prerequisite->getTitle() . '" fulfilled.');
}
}
return $result;
}
/**
* @param UpgradeWizardInterface $instance
* @return int
*/
protected function runSingleWizard(
UpgradeWizardInterface $instance
): int {
$this->output->title('Running Wizard ' . $instance->getTitle());
if ($instance instanceof ConfirmableInterface) {
$confirmation = $instance->getConfirmation();
$defaultString = $confirmation->getDefaultValue() ? 'Y/n' : 'y/N';
$question = new ConfirmationQuestion(
sprintf(
'<info>%s</info>' . LF . '%s' . LF . '%s %s (%s)',
$confirmation->getTitle(),
$confirmation->getMessage(),
$confirmation->getConfirm(),
$confirmation->getDeny(),
$defaultString
),
$confirmation->getDefaultValue()
);
$helper = $this->getHelper('question');
if (!$helper->ask($this->input, $this->output, $question)) {
if ($confirmation->isRequired()) {
$this->output->error('You have to acknowledge this wizard to continue');
return 1;
}
if ($instance instanceof RepeatableInterface) {
$this->output->note('No changes applied.');
} else {
$this->upgradeWizardsService->markWizardAsDone($instance->getIdentifier());
$this->output->note('No changes applied, marking wizard as done.');
}
return 0;
}
}
if ($instance->executeUpdate()) {
$this->output->success('Successfully ran wizard ' . $instance->getTitle());
if (!$instance instanceof RepeatableInterface) {
$this->upgradeWizardsService->markWizardAsDone($instance->getIdentifier());
}
return 0;
}
$this->output->error('<error>Something went wrong while running ' . $instance->getTitle() . '</error>');
return 1;
}
/**
* Get list of registered upgrade wizards.
*
* @return int 0 if all wizards were successful, 1 on error
*/
public function runAllWizards(): int
{
$returnCode = 0;
$wizardInstances = [];
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'] as $identifier => $class) {
$wizardInstances[] = $this->getWizard($class, $identifier);
}
$wizardInstances = array_filter($wizardInstances);
if (count($wizardInstances) > 0) {
$prerequisitesResult = $this->handlePrerequisites($wizardInstances);
if ($prerequisitesResult === false) {
$returnCode = 1;
$this->output->error('Error handling prerequisites, aborting.');
} else {
$this->output->title('Found ' . count($wizardInstances) . ' wizard(s) to run.');
foreach ($wizardInstances as $wizardInstance) {
$result = $this->runSingleWizard($wizardInstance);
if ($result > 0) {
$returnCode = 1;
}
}
}
} else {
$this->output->success('No wizards left to run.');
}
return $returnCode;
}
}