2 namespace TYPO3\CMS\Install\Report
;
5 * This file is part of the TYPO3 CMS project.
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.
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
14 * The TYPO3 project - inspiring people to share!
16 use TYPO3\CMS\Backend\Utility\BackendUtility
;
19 * Provides an installation status report
21 * @author Ingo Renner <ingo@typo3.org>
23 class InstallStatusReport
implements \TYPO3\CMS\Reports\StatusProviderInterface
{
25 protected $reportList = 'FileSystem,RemainingUpdates';
28 * Compiles a collection of system status checks as a status report.
30 * @return array<\TYPO3\CMS\Reports\Status>
32 public function getStatus() {
34 $reportMethods = explode(',', $this->reportList
);
35 foreach ($reportMethods as $reportMethod) {
36 $reports[$reportMethod] = $this->{'get' . $reportMethod . 'Status'}();
42 * Checks for several directories being writable.
44 * @return \TYPO3\CMS\Reports\Status Indicates status of the file system
46 protected function getFileSystemStatus() {
47 $value = $GLOBALS['LANG']->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_writable');
49 $severity = \TYPO3\CMS\Reports\Status
::OK
;
51 // -1 = not required, but if it exists may be writable or not
52 // 0 = not required, if it exists the dir should be writable
53 // 1 = required, don't has to be writable
54 // 2 = required, has to be writable
55 $checkWritable = array(
57 'typo3temp/pics/' => 2,
58 'typo3temp/temp/' => 2,
59 'typo3temp/llxml/' => 2,
62 'typo3temp/locks/' => 2,
64 'typo3conf/ext/' => 0,
65 'typo3conf/l10n/' => 0,
66 TYPO3_mainDir
. 'ext/' => -1,
69 'uploads/media/' => 0,
70 $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] => -1,
71 $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] . '_temp_/' => 0
73 foreach ($checkWritable as $relPath => $requirementLevel) {
74 if (!@is_dir
((PATH_site
. $relPath))) {
75 // If the directory is missing, try to create it
76 \TYPO3\CMS\Core\Utility\GeneralUtility
::mkdir(PATH_site
. $relPath);
78 if (!@is_dir
((PATH_site
. $relPath))) {
79 if ($requirementLevel > 0) {
80 // directory is required
81 $value = $GLOBALS['LANG']->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_missingDirectory');
82 $message .= sprintf($GLOBALS['LANG']->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_directoryDoesNotExistCouldNotCreate'), $relPath) . '<br />';
83 $severity = \TYPO3\CMS\Reports\Status
::ERROR
;
85 $message .= sprintf($GLOBALS['LANG']->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_directoryDoesNotExist'), $relPath);
86 if ($requirementLevel == 0) {
87 $message .= ' ' . $GLOBALS['LANG']->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_directoryShouldAlsoBeWritable');
90 if ($severity < \TYPO3\CMS\Reports\Status
::WARNING
) {
91 $value = $GLOBALS['LANG']->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_nonExistingDirectory');
92 $severity = \TYPO3\CMS\Reports\Status
::WARNING
;
96 if (!is_writable((PATH_site
. $relPath))) {
97 switch ($requirementLevel) {
99 $message .= sprintf($GLOBALS['LANG']->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_directoryShouldBeWritable'), (PATH_site
. $relPath)) . '<br />';
100 if ($severity < \TYPO3\CMS\Reports\Status
::WARNING
) {
101 $value = $GLOBALS['LANG']->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_recommendedWritableDirectory');
102 $severity = \TYPO3\CMS\Reports\Status
::WARNING
;
106 $value = $GLOBALS['LANG']->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_requiredWritableDirectory');
107 $message .= sprintf($GLOBALS['LANG']->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_directoryMustBeWritable'), (PATH_site
. $relPath)) . '<br />';
108 $severity = \TYPO3\CMS\Reports\Status
::ERROR
;
114 return \TYPO3\CMS\Core\Utility\GeneralUtility
::makeInstance(\TYPO3\CMS\Reports\Status
::class, $GLOBALS['LANG']->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_fileSystem'), $value, $message, $severity);
118 * Checks if there are still updates to perform
120 * @return \TYPO3\CMS\Reports\Status Represents whether the installation is completely updated yet
122 protected function getRemainingUpdatesStatus() {
123 $value = $GLOBALS['LANG']->getLL('status_updateComplete');
125 $severity = \TYPO3\CMS\Reports\Status
::OK
;
126 if (!\TYPO3\CMS\Core\Utility\GeneralUtility
::compat_version(TYPO3_branch
)) {
127 $value = $GLOBALS['LANG']->getLL('status_updateIncomplete');
128 $severity = \TYPO3\CMS\Reports\Status
::WARNING
;
129 $url = BackendUtility
::getModuleUrl('system_InstallInstall');
130 $message = sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:warning.install_update'), '<a href="' . htmlspecialchars($url) . '">', '</a>');
132 return \TYPO3\CMS\Core\Utility\GeneralUtility
::makeInstance(\TYPO3\CMS\Reports\Status
::class, $GLOBALS['LANG']->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_remainingUpdates'), $value, $message, $severity);