TYPO3  7.6
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 = array();
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 = array(
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'])) {
145  $versionAsInt = \TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version);
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 
162 
168  protected function getNewVersionStatus()
169  {
170  $languageService = $this->getLanguageService();
172  $objectManager = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
174  $coreVersionService = $objectManager->get(\TYPO3\CMS\Install\Service\CoreVersionService::class);
175 
176  // No updates for development versions
177  if (!$coreVersionService->isInstalledVersionAReleasedVersion()) {
178  return GeneralUtility::makeInstance(Status::class, 'TYPO3', TYPO3_version, $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_isDevelopmentVersion'), Status::NOTICE);
179  }
180 
181  // If fetching version matrix fails we can not do anything except print out the current version
182  try {
183  $coreVersionService->updateVersionMatrix();
184  } catch (Exception\RemoteFetchException $remoteFetchException) {
185  return GeneralUtility::makeInstance(Status::class, 'TYPO3', TYPO3_version, $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_remoteFetchException'), Status::NOTICE);
186  }
187 
188  try {
189  $isUpdateAvailable = $coreVersionService->isYoungerPatchReleaseAvailable();
190  $isMaintainedVersion = $coreVersionService->isVersionActivelyMaintained();
191  } catch (Exception\CoreVersionServiceException $coreVersionServiceException) {
192  return GeneralUtility::makeInstance(Status::class, 'TYPO3', TYPO3_version, $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_patchLevelNotFoundInReleaseMatrix'), Status::WARNING);
193  }
194 
195  if (!$isUpdateAvailable && $isMaintainedVersion) {
196  // Everything is fine, working with the latest version
197  $message = '';
198  $status = Status::OK;
199  } elseif ($isUpdateAvailable) {
200  // There is an update available
201  $newVersion = $coreVersionService->getYoungestPatchRelease();
202  if ($coreVersionService->isUpdateSecurityRelevant()) {
203  $message = sprintf($languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_newVersionSecurityRelevant'), $newVersion);
204  $status = Status::ERROR;
205  } else {
206  $message = sprintf($languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_newVersion'), $newVersion);
207  $status = Status::WARNING;
208  }
209  } else {
210  // Version is not maintained
211  $message = $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_versionOutdated');
212  $status = Status::ERROR;
213  }
214 
215  return GeneralUtility::makeInstance(Status::class, 'TYPO3', TYPO3_version, $message, $status);
216  }
217 
221  protected function getLanguageService()
222  {
223  return $GLOBALS['LANG'];
224  }
225 }