TYPO3 CMS  TYPO3_7-6
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 
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/pics/' => 2,
67  'typo3temp/temp/' => 2,
68  'typo3temp/llxml/' => 2,
69  'typo3temp/cs/' => 2,
70  'typo3temp/GB/' => 2,
71  'typo3temp/locks/' => 2,
72  'typo3conf/' => 2,
73  'typo3conf/ext/' => 0,
74  'typo3conf/l10n/' => 0,
75  'uploads/' => 2,
76  'uploads/pics/' => 0,
77  'uploads/media/' => 0,
78  $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] => -1,
79  $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] . '_temp_/' => 0,
80  ];
81 
82  if ($GLOBALS['TYPO3_CONF_VARS']['EXT']['allowGlobalInstall']) {
83  $checkWritable[TYPO3_mainDir . 'ext/'] = -1;
84  }
85 
86  foreach ($checkWritable as $relPath => $requirementLevel) {
87  if (!@is_dir(PATH_site . $relPath)) {
88  // If the directory is missing, try to create it
89  GeneralUtility::mkdir(PATH_site . $relPath);
90  }
91  if (!@is_dir(PATH_site . $relPath)) {
92  if ($requirementLevel > 0) {
93  // directory is required
94  $value = $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_missingDirectory');
95  $message .= sprintf($languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_directoryDoesNotExistCouldNotCreate'), $relPath) . '<br />';
96  $severity = Status::ERROR;
97  } else {
98  $message .= sprintf($languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_directoryDoesNotExist'), $relPath);
99  if ($requirementLevel == 0) {
100  $message .= ' ' . $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_directoryShouldAlsoBeWritable');
101  }
102  $message .= '<br />';
103  if ($severity < Status::WARNING) {
104  $value = $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_nonExistingDirectory');
105  $severity = Status::WARNING;
106  }
107  }
108  } else {
109  if (!is_writable((PATH_site . $relPath))) {
110  switch ($requirementLevel) {
111  case 0:
112  $message .= sprintf($languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_directoryShouldBeWritable'), (PATH_site . $relPath)) . '<br />';
113  if ($severity < Status::WARNING) {
114  $value = $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_recommendedWritableDirectory');
115  $severity = Status::WARNING;
116  }
117  break;
118  case 2:
119  $value = $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_requiredWritableDirectory');
120  $message .= sprintf($languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_directoryMustBeWritable'), (PATH_site . $relPath)) . '<br />';
121  $severity = Status::ERROR;
122  break;
123  default:
124  }
125  }
126  }
127  }
128  return GeneralUtility::makeInstance(Status::class, $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_fileSystem'), $value, $message, $severity);
129  }
130 
136  protected function getRemainingUpdatesStatus()
137  {
138  $languageService = $this->getLanguageService();
139  $value = $languageService->getLL('status_updateComplete');
140  $message = '';
141  $severity = Status::OK;
142 
143  // check if there are update wizards left to perform
144  if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'])) {
146  foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'] as $identifier => $className) {
147  $updateObject = GeneralUtility::makeInstance($className, $identifier, $versionAsInt, null, $this);
148  if ($updateObject->shouldRenderWizard()) {
149  // at least one wizard was found
150  $value = $languageService->getLL('status_updateIncomplete');
151  $severity = Status::WARNING;
152  $url = BackendUtility::getModuleUrl('system_InstallInstall');
153  $message = sprintf($languageService->sL('LLL:EXT:lang/locallang_core.xlf:warning.install_update'), '<a href="' . htmlspecialchars($url) . '">', '</a>');
154  break;
155  }
156  }
157  }
158 
159  return GeneralUtility::makeInstance(Status::class, $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_remainingUpdates'), $value, $message, $severity);
160  }
161 
167  protected function getNewVersionStatus()
168  {
169  $languageService = $this->getLanguageService();
171  $objectManager = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
173  $coreVersionService = $objectManager->get(\TYPO3\CMS\Install\Service\CoreVersionService::class);
174 
175  // No updates for development versions
176  if (!$coreVersionService->isInstalledVersionAReleasedVersion()) {
177  return GeneralUtility::makeInstance(Status::class, 'TYPO3', TYPO3_version, $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_isDevelopmentVersion'), Status::NOTICE);
178  }
179 
180  // If fetching version matrix fails we can not do anything except print out the current version
181  try {
182  $coreVersionService->updateVersionMatrix();
183  } catch (Exception\RemoteFetchException $remoteFetchException) {
184  return GeneralUtility::makeInstance(Status::class, 'TYPO3', TYPO3_version, $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_remoteFetchException'), Status::NOTICE);
185  }
186 
187  try {
188  $isUpdateAvailable = $coreVersionService->isYoungerPatchReleaseAvailable();
189  $isMaintainedVersion = $coreVersionService->isVersionActivelyMaintained();
190  } catch (Exception\CoreVersionServiceException $coreVersionServiceException) {
191  return GeneralUtility::makeInstance(Status::class, 'TYPO3', TYPO3_version, $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_patchLevelNotFoundInReleaseMatrix'), Status::WARNING);
192  }
193 
194  if (!$isUpdateAvailable && $isMaintainedVersion) {
195  // Everything is fine, working with the latest version
196  $message = '';
197  $status = Status::OK;
198  } elseif ($isUpdateAvailable) {
199  // There is an update available
200  $newVersion = $coreVersionService->getYoungestPatchRelease();
201  if ($coreVersionService->isUpdateSecurityRelevant()) {
202  $message = sprintf($languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_newVersionSecurityRelevant'), $newVersion);
203  $status = Status::ERROR;
204  } else {
205  $message = sprintf($languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_newVersion'), $newVersion);
206  $status = Status::WARNING;
207  }
208  } else {
209  // Version is not maintained
210  $message = $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_versionOutdated');
211  $status = Status::ERROR;
212  }
213 
214  return GeneralUtility::makeInstance(Status::class, 'TYPO3', TYPO3_version, $message, $status);
215  }
216 
220  protected function getLanguageService()
221  {
222  return $GLOBALS['LANG'];
223  }
224 }
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']