TYPO3 CMS  TYPO3_8-7
InstallStatusReport.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
23 
28 {
32  protected $reportList = 'FileSystem,RemainingUpdates,NewVersion';
33 
39  public function getStatus()
40  {
41  $reports = [];
42  $reportMethods = explode(',', $this->reportList);
43  foreach ($reportMethods as $reportMethod) {
44  $reports[$reportMethod] = $this->{'get' . $reportMethod . 'Status'}();
45  }
46  return $reports;
47  }
48 
54  protected function getFileSystemStatus()
55  {
56  $languageService = $this->getLanguageService();
57  $value = $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_writable');
58  $message = '';
59  $severity = Status::OK;
60  // Requirement level
61  // -1 = not required, but if it exists may be writable or not
62  // 0 = not required, if it exists the dir should be writable
63  // 1 = required, doesn't have to be writable
64  // 2 = required, has to be writable
65  $checkWritable = [
66  'typo3temp/' => 2,
67  'typo3temp/assets/' => 2,
68  'typo3temp/assets/compressed/' => 2,
69  // only needed when GraphicalFunctions is used
70  'typo3temp/assets/images/' => 0,
71  // used in PageGenerator (inlineStyle2Temp) and Backend + Language JS files
72  'typo3temp/assets/css/' => 2,
73  'typo3temp/assets/js/' => 2,
74  // fallback storage of FAL
75  'typo3temp/assets/_processed_/' => 0,
76  'typo3temp/var/' => 2,
77  'typo3temp/var/transient/' => 2,
78  'typo3temp/var/charset/' => 2,
79  'typo3temp/var/locks/' => 2,
80  'typo3conf/' => 2,
81  'typo3conf/ext/' => 0,
82  'typo3conf/l10n/' => 0,
83  'uploads/' => 2,
84  'uploads/media/' => 0,
85  $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] => -1,
86  $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] . '_temp_/' => 0,
87  ];
88 
89  if ($GLOBALS['TYPO3_CONF_VARS']['EXT']['allowGlobalInstall']) {
90  $checkWritable[TYPO3_mainDir . 'ext/'] = -1;
91  }
92 
93  foreach ($checkWritable as $relPath => $requirementLevel) {
94  if (!@is_dir(PATH_site . $relPath)) {
95  // If the directory is missing, try to create it
96  GeneralUtility::mkdir(PATH_site . $relPath);
97  }
98  if (!@is_dir(PATH_site . $relPath)) {
99  if ($requirementLevel > 0) {
100  // directory is required
101  $value = $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_missingDirectory');
102  $message .= sprintf($languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_directoryDoesNotExistCouldNotCreate'), $relPath) . '<br />';
103  $severity = Status::ERROR;
104  } else {
105  $message .= sprintf($languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_directoryDoesNotExist'), $relPath);
106  if ($requirementLevel == 0) {
107  $message .= ' ' . $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_directoryShouldAlsoBeWritable');
108  }
109  $message .= '<br />';
110  if ($severity < Status::WARNING) {
111  $value = $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_nonExistingDirectory');
112  $severity = Status::WARNING;
113  }
114  }
115  } else {
116  if (!is_writable((PATH_site . $relPath))) {
117  switch ($requirementLevel) {
118  case 0:
119  $message .= sprintf($languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_directoryShouldBeWritable'), (PATH_site . $relPath)) . '<br />';
120  if ($severity < Status::WARNING) {
121  $value = $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_recommendedWritableDirectory');
122  $severity = Status::WARNING;
123  }
124  break;
125  case 2:
126  $value = $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_requiredWritableDirectory');
127  $message .= sprintf($languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_directoryMustBeWritable'), (PATH_site . $relPath)) . '<br />';
128  $severity = Status::ERROR;
129  break;
130  default:
131  }
132  }
133  }
134  }
135  return GeneralUtility::makeInstance(Status::class, $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_fileSystem'), $value, $message, $severity);
136  }
137 
143  protected function getRemainingUpdatesStatus()
144  {
145  $languageService = $this->getLanguageService();
146  $value = $languageService->getLL('status_updateComplete');
147  $message = '';
148  $severity = Status::OK;
149 
150  // check if there are update wizards left to perform
151  if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'])) {
153  $registry = GeneralUtility::makeInstance(Registry::class);
154  foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'] as $identifier => $className) {
155  $updateObject = GeneralUtility::makeInstance($className, $identifier, $versionAsInt, null, $this);
156  $markedDoneInRegistry = $registry->get('installUpdate', $className, false);
157  if (!$markedDoneInRegistry && $updateObject->shouldRenderWizard()) {
158  // at least one wizard was found
159  $value = $languageService->getLL('status_updateIncomplete');
160  $severity = Status::WARNING;
161  $url = BackendUtility::getModuleUrl('system_extinstall');
162  $message = sprintf($languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:warning.install_update'), '<a href="' . htmlspecialchars($url) . '">', '</a>');
163  break;
164  }
165  }
166  }
167 
168  return GeneralUtility::makeInstance(Status::class, $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_remainingUpdates'), $value, $message, $severity);
169  }
170 
176  protected function getNewVersionStatus()
177  {
178  $languageService = $this->getLanguageService();
180  $coreVersionService = GeneralUtility::makeInstance(\TYPO3\CMS\Install\Service\CoreVersionService::class);
181 
182  // No updates for development versions
183  if (!$coreVersionService->isInstalledVersionAReleasedVersion()) {
184  return GeneralUtility::makeInstance(Status::class, 'TYPO3', TYPO3_version, $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_isDevelopmentVersion'), Status::NOTICE);
185  }
186 
187  // If fetching version matrix fails we can not do anything except print out the current version
188  try {
189  $coreVersionService->updateVersionMatrix();
190  } catch (Exception\RemoteFetchException $remoteFetchException) {
191  return GeneralUtility::makeInstance(Status::class, 'TYPO3', TYPO3_version, $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_remoteFetchException'), Status::NOTICE);
192  }
193 
194  try {
195  $isUpdateAvailable = $coreVersionService->isYoungerPatchReleaseAvailable();
196  $isMaintainedVersion = $coreVersionService->isVersionActivelyMaintained();
197  } catch (Exception\CoreVersionServiceException $coreVersionServiceException) {
198  return GeneralUtility::makeInstance(Status::class, 'TYPO3', TYPO3_version, $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_patchLevelNotFoundInReleaseMatrix'), Status::WARNING);
199  }
200 
201  if (!$isUpdateAvailable && $isMaintainedVersion) {
202  // Everything is fine, working with the latest version
203  $message = '';
204  $status = Status::OK;
205  } elseif ($isUpdateAvailable) {
206  // There is an update available
207  $newVersion = $coreVersionService->getYoungestPatchRelease();
208  if ($coreVersionService->isUpdateSecurityRelevant()) {
209  $message = sprintf($languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_newVersionSecurityRelevant'), $newVersion);
210  $status = Status::ERROR;
211  } else {
212  $message = sprintf($languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_newVersion'), $newVersion);
213  $status = Status::WARNING;
214  }
215  } else {
216  // Version is not maintained
217  $message = $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_versionOutdated');
218  $status = Status::ERROR;
219  }
220 
221  return GeneralUtility::makeInstance(Status::class, 'TYPO3', TYPO3_version, $message, $status);
222  }
223 
227  protected function getLanguageService()
228  {
229  return $GLOBALS['LANG'];
230  }
231 }
static makeInstance($className,... $constructorArguments)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']