diff --git a/typo3/sysext/core/Documentation/Changelog/master/Breaking-93081-RemovedFetchingTranslationFileMirrorFromTypo3org.rst b/typo3/sysext/core/Documentation/Changelog/master/Breaking-93081-RemovedFetchingTranslationFileMirrorFromTypo3org.rst new file mode 100644 index 0000000000000000000000000000000000000000..b861d3fb838d13b577b65a4b6121baccdc0ef0ef --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Breaking-93081-RemovedFetchingTranslationFileMirrorFromTypo3org.rst @@ -0,0 +1,36 @@ +.. include:: ../../Includes.txt + +========================================================================== +Breaking: #93081 - Removed fetching translation file mirror from typo3.org +========================================================================== + +See :issue:`93081` + +Description +=========== + +The process of downloading translation of XLF files has been simplified. +The URL `https://localize.typo3.org/xliff/` is always used instead of download a static XML +file from typo3.org and persisting the URL in the registry. + + +Impact +====== + +The URL `https://localize.typo3.org/xliff/` is always used and typo3.org is not contacted anymore. + +If any extension has overriden the information in the registry, this path won't be taken into account anymore. + + +Affected Installations +====================== + +Any TYPO3 installation which uses a different URL to fetch translations of TYPO3 core or any extension. + + +Migration +========= + +Use the existing event :php:`ModifyLanguagePackRemoteBaseUrlEvent` to change the URL used to fetch translations. + +.. index:: Backend, Frontend, NotScanned, ext:install diff --git a/typo3/sysext/install/Classes/Command/LanguagePackCommand.php b/typo3/sysext/install/Classes/Command/LanguagePackCommand.php index a48a591cf8816668565ef93062f967161ffb6fae..bbec4eab1cca2874884af8ce6fc74239c863eb24 100644 --- a/typo3/sysext/install/Classes/Command/LanguagePackCommand.php +++ b/typo3/sysext/install/Classes/Command/LanguagePackCommand.php @@ -92,7 +92,6 @@ class LanguagePackCommand extends Command $progressBarOutput = $output; } $progressBar = new ProgressBar($progressBarOutput, count($isos) * count($extensions)); - $languagePackService->updateMirrorBaseUrl(); $hasErrors = false; foreach ($isos as $iso) { foreach ($extensions as $extension) { diff --git a/typo3/sysext/install/Classes/Controller/MaintenanceController.php b/typo3/sysext/install/Classes/Controller/MaintenanceController.php index 1828744503695a0df3704d2333b6712cbc1d1e45..97bebbd22347063244891d6ac340bb737c361bfa 100644 --- a/typo3/sysext/install/Classes/Controller/MaintenanceController.php +++ b/typo3/sysext/install/Classes/Controller/MaintenanceController.php @@ -644,7 +644,6 @@ class MaintenanceController extends AbstractController ]); // This action needs TYPO3_CONF_VARS for full GeneralUtility::getUrl() config $this->lateBootService->loadExtLocalconfDatabaseAndExtTables(); - $this->languagePackService->updateMirrorBaseUrl(); $extensions = $this->languagePackService->getExtensionLanguagePackDetails(); return new JsonResponse([ 'success' => true, diff --git a/typo3/sysext/install/Classes/Service/LanguagePackService.php b/typo3/sysext/install/Classes/Service/LanguagePackService.php index 310c321f8a98999ad7974933eaec33a25e9702b9..4dde9c2276d81998f6f2502efa237bcb9b643521 100644 --- a/typo3/sysext/install/Classes/Service/LanguagePackService.php +++ b/typo3/sysext/install/Classes/Service/LanguagePackService.php @@ -24,6 +24,7 @@ use Symfony\Component\Finder\Finder; use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Http\RequestFactory; use TYPO3\CMS\Core\Http\Uri; +use TYPO3\CMS\Core\Information\Typo3Version; use TYPO3\CMS\Core\Localization\Locales; use TYPO3\CMS\Core\Package\PackageManager; use TYPO3\CMS\Core\Registry; @@ -63,11 +64,6 @@ class LanguagePackService implements LoggerAwareInterface */ protected $requestFactory; - private const OLD_LANGUAGE_PACK_URLS = [ - 'https://typo3.org/fileadmin/ter/', - 'https://beta-translation.typo3.org/fileadmin/ter/', - 'https://localize.typo3.org/fileadmin/ter/' - ]; private const LANGUAGE_PACK_URL = 'https://localize.typo3.org/xliff/'; public function __construct(EventDispatcherInterface $eventDispatcher, RequestFactory $requestFactory) @@ -200,43 +196,6 @@ class LanguagePackService implements LoggerAwareInterface return $extensions; } - /** - * Update main language pack download location if possible. - * Store to registry to be used during language pack update - * - * @return string - */ - public function updateMirrorBaseUrl(): string - { - $repositoryUrl = 'https://repositories.typo3.org/mirrors.xml.gz'; - $downloadBaseUrl = false; - try { - $response = $this->requestFactory->request($repositoryUrl); - if ($response->getStatusCode() === 200) { - $xmlContent = @gzdecode($response->getBody()->getContents()); - if (!empty($xmlContent['mirror']['host']) && !empty($xmlContent['mirror']['path'])) { - $downloadBaseUrl = 'https://' . $xmlContent['mirror']['host'] . $xmlContent['mirror']['path']; - } - } else { - $this->logger->warning(sprintf( - 'Requesting %s was not successful, got status code %d (%s)', - $repositoryUrl, - $response->getStatusCode(), - $response->getReasonPhrase() - )); - } - } catch (\Exception $e) { - // Catch generic exception, fallback handled below - $this->logger->error('Failed to download list of mirrors', ['exception' => $e]); - } - if (empty($downloadBaseUrl)) { - // Hard coded fallback if something went wrong fetching & parsing mirror list - $downloadBaseUrl = self::LANGUAGE_PACK_URL; - } - $this->registry->set('languagePacks', 'baseUrl', $downloadBaseUrl); - return $downloadBaseUrl; - } - /** * Download and unpack a single language pack of one extension. * @@ -266,20 +225,13 @@ class LanguagePackService implements LoggerAwareInterface throw new \RuntimeException('Extension ' . (string)$key . ' not loaded', 1520117245); } - $languagePackBaseUrl = $this->registry->get('languagePacks', 'baseUrl'); - if (empty($languagePackBaseUrl)) { - throw new \RuntimeException('Language pack baseUrl not found', 1520169691); - } - - if (in_array($languagePackBaseUrl, self::OLD_LANGUAGE_PACK_URLS, true)) { - $languagePackBaseUrl = self::LANGUAGE_PACK_URL; - } + $languagePackBaseUrl = self::LANGUAGE_PACK_URL; // Allow to modify the base url on the fly $event = $this->eventDispatcher->dispatch(new ModifyLanguagePackRemoteBaseUrlEvent(new Uri($languagePackBaseUrl), $key)); $languagePackBaseUrl = $event->getBaseUrl(); $path = ExtensionManagementUtility::extPath($key); - $majorVersion = explode('.', TYPO3_branch)[0]; + $majorVersion = GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion(); if (strpos($path, '/sysext/') !== false) { // This is a system extension and the package URL should be adapted to have different packs per core major version // https://localize.typo3.org/xliff/b/a/backend-l10n/backend-l10n-fr.v9.zip @@ -344,12 +296,11 @@ class LanguagePackService implements LoggerAwareInterface public function setLastUpdatedIsoCode(array $isos) { $activeLanguages = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['lang']['availableLanguages'] ?? []; - $registry = GeneralUtility::makeInstance(Registry::class); foreach ($isos as $iso) { if (!in_array($iso, $activeLanguages, true)) { throw new \RuntimeException('Language iso code ' . (string)$iso . ' not available or active', 1520176318); } - $registry->set('languagePacks', $iso, time()); + $this->registry->set('languagePacks', $iso, time()); } }