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