77 $this->coreVersionService =
$coreVersionService ?: GeneralUtility::makeInstance(CoreVersionService::class);
80 $this->downloadBaseUri =
'https://get.typo3.org';
91 $coreUpdateDisabled = getenv(
'TYPO3_DISABLE_CORE_UPDATER') ?: (getenv(
'REDIRECT_TYPO3_DISABLE_CORE_UPDATER') ?:
false);
138 'The method updateVersionMatrix() is deprecated since TYPO3 v9 and will be removed in TYPO3 v10.0, use the REST api directly (see https://get.typo3.org/v1/api/doc).',
143 $this->coreVersionService->getYoungestPatchRelease();
144 }
catch (RemoteFetchException $e) {
146 $this->messages->enqueue(
new FlashMessage(
147 'Current version specification could not be fetched from https://get.typo3.org.'
148 .
' This is probably a network issue, please fix it.',
149 'Version information could not be fetched from get.typo3.org',
167 $folderStructureFacade = GeneralUtility::makeInstance(DefaultFactory::class)->getStructure();
168 $folderStructureMessageQueue = $folderStructureFacade->getStatus();
171 if (!empty($folderStructureErrors) || !empty($folderStructureWarnings) || !is_link(
Environment::getPublicPath() .
'/typo3_src')) {
173 $this->messages->enqueue(
new FlashMessage(
174 'To perform an update, the folder structure of this TYPO3 CMS instance must'
175 .
' stick to the conventions, or the update process could lead to unexpected'
176 .
' results and may be hazardous to your system',
177 'Automatic TYPO3 CMS core update not possible: Folder structure has errors or warnings',
185 $this->messages->enqueue(
new FlashMessage(
187 'Automatic TYPO3 CMS core update not possible: Update not supported on Windows OS',
195 $result = @touch($file);
198 $this->messages->enqueue(
new FlashMessage(
200 'Automatic TYPO3 CMS core update not possible: No write access to document root',
206 @symlink($file, $link);
207 if (!is_link($link)) {
209 $this->messages->enqueue(
new FlashMessage(
211 'Automatic TYPO3 CMS core update not possible: No symlink creation possible',
222 $coreLocation = @realpath($this->symlinkToCoreFiles .
'/../');
224 $result = @touch($file);
227 $this->messages->enqueue(
new FlashMessage(
228 'New TYPO3 CMS core should be installed in "' . $coreLocation .
'", but this directory is not writable!',
229 'Automatic TYPO3 CMS core update not possible: No write access to TYPO3 CMS core location',
238 if ($success && !$this->coreVersionService->isInstalledVersionAReleasedVersion()) {
240 $this->messages->enqueue(
new FlashMessage(
241 'Your current version is specified as ' . $this->coreVersionService->getInstalledVersion() .
'.'
242 .
' This is a development version and can not be updated automatically. If this is a "git"'
243 .
' checkout, please update using git directly.',
244 'Automatic TYPO3 CMS core update not possible: You are running a development version of TYPO3',
260 $version = $coreRelease->getVersion();
263 $this->messages->enqueue(
new FlashMessage(
265 'Skipped download of TYPO3 CMS core. A core source directory already exists in destination path. Using this instead.',
269 $downloadUri = $this->downloadBaseUri .
'/' . $version;
272 if (@file_exists($fileLocation)) {
274 $this->messages->enqueue(
new FlashMessage(
280 $fileContent = GeneralUtility::getUrl($downloadUri);
283 $this->messages->enqueue(
new FlashMessage(
284 'Failed to download ' . $downloadUri,
285 'Download not successful',
289 $fileStoreResult = file_put_contents($fileLocation, $fileContent);
290 if (!$fileStoreResult) {
292 $this->messages->enqueue(
new FlashMessage(
294 'Unable to store download content',
298 $this->messages->enqueue(
new FlashMessage(
300 'TYPO3 CMS core download finished'
317 $version = $coreRelease->getVersion();
320 $this->messages->enqueue(
new FlashMessage(
322 'Verifying existing TYPO3 CMS core checksum is not possible',
327 $expectedChecksum = $coreRelease->getChecksum();
328 if (!file_exists($fileLocation)) {
330 $this->messages->enqueue(
new FlashMessage(
332 'Downloaded TYPO3 CMS core not found',
336 $actualChecksum = sha1_file($fileLocation);
337 if ($actualChecksum !== $expectedChecksum) {
339 $this->messages->enqueue(
new FlashMessage(
340 'The official TYPO3 CMS version system on https://get.typo3.org expects a sha1 checksum of '
341 . $expectedChecksum .
' from the content of the downloaded new TYPO3 CMS core version ' . $version .
'.'
342 .
' The actual checksum is ' . $actualChecksum .
'. The update is stopped. This may be a'
343 .
' failed download, an attack, or an issue with the typo3.org infrastructure.',
344 'New TYPO3 CMS core checksum mismatch',
348 $this->messages->enqueue(
new FlashMessage(
366 $version = $coreRelease->getVersion();
369 $this->messages->enqueue(
new FlashMessage(
371 'Unpacking TYPO3 CMS core files skipped',
375 $fileLocation = $this->downloadTargetPath . $version .
'.tar.gz';
376 if (!@is_file($fileLocation)) {
378 $this->messages->enqueue(
new FlashMessage(
380 'Downloaded TYPO3 CMS core not found',
383 } elseif (@file_exists($this->downloadTargetPath .
'typo3_src-' . $version)) {
385 $this->messages->enqueue(
new FlashMessage(
391 $unpackCommand =
'tar xf ' . escapeshellarg($fileLocation) .
' -C ' . escapeshellarg($this->downloadTargetPath) .
' 2>&1';
392 exec($unpackCommand,
$output, $errorCode);
395 $this->messages->enqueue(
new FlashMessage(
397 'Unpacking TYPO3 CMS core not successful',
401 $removePackedFileResult = unlink($fileLocation);
402 if (!$removePackedFileResult) {
404 $this->messages->enqueue(
new FlashMessage(
406 'Removing packed TYPO3 CMS core not successful',
410 $this->messages->enqueue(
new FlashMessage(
412 'Unpacking TYPO3 CMS core successful'
429 $version = $coreRelease->getVersion();
432 $this->messages->enqueue(
new FlashMessage(
434 'Moving TYPO3 CMS core files skipped',
438 $downloadedCoreLocation = $this->downloadTargetPath .
'typo3_src-' . $version;
439 $newCoreLocation = @realpath($this->symlinkToCoreFiles .
'/../') .
'/typo3_src-' . $version;
441 if (!@is_dir($downloadedCoreLocation)) {
443 $this->messages->enqueue(
new FlashMessage(
445 'Unpacked TYPO3 CMS core not found',
449 $moveResult = rename($downloadedCoreLocation, $newCoreLocation);
452 $this->messages->enqueue(
new FlashMessage(
454 'Moving TYPO3 CMS core to ' . $newCoreLocation .
' failed',
458 $this->messages->enqueue(
new FlashMessage(
460 'Moved TYPO3 CMS core to final location'
476 $newCoreLocation = @realpath($this->symlinkToCoreFiles .
'/../') .
'/typo3_src-' . $coreRelease->getVersion();
478 if (!is_dir($newCoreLocation)) {
480 $this->messages->enqueue(
new FlashMessage(
482 'New TYPO3 CMS core not found',
485 } elseif (!is_link($this->symlinkToCoreFiles)) {
487 $this->messages->enqueue(
new FlashMessage(
489 'TYPO3 CMS core source directory (typo3_src) is not a link',
494 $unlinkResult = unlink($this->symlinkToCoreFiles);
495 if (!$unlinkResult) {
497 $this->messages->enqueue(
new FlashMessage(
499 'Removing old symlink failed',
503 if (!$isCurrentCoreSymlinkAbsolute) {
506 $symlinkResult = symlink($newCoreLocation, $this->symlinkToCoreFiles);
507 if ($symlinkResult) {
508 GeneralUtility::makeInstance(OpcodeCacheService::class)->clearAllActive();
511 $this->messages->enqueue(
new FlashMessage(
513 'Linking new TYPO3 CMS core failed',
530 return $this->downloadTargetPath . $version .
'.tar.gz';
542 $targetPath = explode(DIRECTORY_SEPARATOR, rtrim($absolutePath, DIRECTORY_SEPARATOR));
543 while (count($sourcePath) && count($targetPath) && $sourcePath[0] === $targetPath[0]) {
544 array_shift($sourcePath);
545 array_shift($targetPath);
547 return str_pad(
'', count($sourcePath) * 3,
'..' . DIRECTORY_SEPARATOR) . implode(DIRECTORY_SEPARATOR, $targetPath);
559 $newCoreLocation = @realpath($this->symlinkToCoreFiles .
'/../') .
'/typo3_src-' . $version;
560 return @is_dir($newCoreLocation);