[FEATURE] Use new REST API for update checks
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / SystemInformation / Typo3VersionMessage.php
1 <?php
2 declare(strict_types = 1);
3
4 namespace TYPO3\CMS\Install\SystemInformation;
5
6 /*
7 * This file is part of the TYPO3 CMS project.
8 *
9 * It is free software; you can redistribute it and/or modify it under
10 * the terms of the GNU General Public License, either version 2
11 * of the License, or any later version.
12 *
13 * For the full copyright and license information, please read the
14 * LICENSE.txt file that was distributed with this source code.
15 *
16 * The TYPO3 project - inspiring people to share!
17 */
18
19 use TYPO3\CMS\Backend\Backend\ToolbarItems\SystemInformationToolbarItem;
20 use TYPO3\CMS\Backend\Toolbar\Enumeration\InformationStatus;
21 use TYPO3\CMS\Core\Utility\GeneralUtility;
22 use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
23 use TYPO3\CMS\Install\Service\CoreVersionService;
24 use TYPO3\CMS\Install\Service\Exception\RemoteFetchException;
25
26 /**
27 * Count newest exceptions for the system information menu
28 */
29 class Typo3VersionMessage
30 {
31 /**
32 * Modifies the SystemInformation array
33 *
34 * @param SystemInformationToolbarItem $systemInformationToolbarItem
35 */
36 public function appendMessage(SystemInformationToolbarItem $systemInformationToolbarItem): void
37 {
38 $coreVersionService = GeneralUtility::makeInstance(CoreVersionService::class);
39
40 try {
41 if ($coreVersionService->isVersionActivelyMaintained()) {
42 $isYoungerPatchReleaseAvailable = $coreVersionService->isYoungerPatchReleaseAvailable();
43
44 if (true === $isYoungerPatchReleaseAvailable) {
45 $release = $coreVersionService->getYoungestPatchRelease();
46
47 if ($coreVersionService->isUpdateSecurityRelevant()) {
48 $severity = InformationStatus::STATUS_ERROR;
49 $message = LocalizationUtility::translate(
50 'LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_newVersionSecurityRelevant'
51 );
52 } else {
53 $severity = InformationStatus::STATUS_WARNING;
54 $message = LocalizationUtility::translate(
55 'LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_newVersion'
56 );
57 }
58
59 $message = sprintf($message, $release);
60 } else {
61 $severity = InformationStatus::STATUS_OK;
62 $message = LocalizationUtility::translate(
63 'LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_uptodate'
64 );
65 }
66 } else {
67 $severity = InformationStatus::STATUS_ERROR;
68 $message = LocalizationUtility::translate(
69 'LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_versionOutdated'
70 );
71 }
72 } catch (RemoteFetchException $exception) {
73 $message = LocalizationUtility::translate(
74 'LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_noAutomaticCheck'
75 );
76 $severity = InformationStatus::STATUS_WARNING;
77 }
78
79 $systemInformationToolbarItem->addSystemMessage(
80 $message,
81 $severity
82 );
83 }
84 }