Beispiel #1
0
 /**
  * Get own status and status of child objects - Root node gives error status if not exists
  *
  * @return array<\TYPO3\CMS\Install\Status\StatusInterface>
  */
 public function getStatus()
 {
     $result = array();
     if (!$this->exists()) {
         $status = new Status\ErrorStatus();
         $status->setTitle($this->getAbsolutePath() . ' does not exist');
         $result[] = $status;
     } else {
         $result = $this->getSelfStatus();
     }
     $result = array_merge($result, $this->getChildrenStatus());
     return $result;
 }
Beispiel #2
0
 /**
  * Get own status
  * Returns information status if running on Windows
  * Returns OK status if is link and possible target is correct
  * Else returns error (not fixable)
  *
  * @return array<\TYPO3\CMS\Install\Status\StatusInterface>
  */
 public function getStatus()
 {
     if ($this->isWindowsOs()) {
         $status = new Status\InfoStatus();
         $status->setTitle($this->getRelativePathBelowSiteRoot() . ' should be a link, but this support is incomplete for Windows.');
         $status->setMessage('This node is not handled for Windows OS and should be checked manually.');
         return [$status];
     }
     if (!$this->exists()) {
         $status = new Status\ErrorStatus();
         $status->setTitle($this->getRelativePathBelowSiteRoot() . ' should be a link, but it does not exist');
         $status->setMessage('Links cannot be fixed by this system');
         return [$status];
     }
     if (!$this->isLink()) {
         $status = new Status\WarningStatus();
         $status->setTitle('Path ' . $this->getRelativePathBelowSiteRoot() . ' is not a link');
         $type = @filetype($this->getAbsolutePath());
         if ($type) {
             $status->setMessage('The target ' . $this->getRelativePathBelowSiteRoot() . ' should be a link,' . ' but is of type ' . $type . '. This cannot be fixed automatically. Please investigate.');
         } else {
             $status->setMessage('The target ' . $this->getRelativePathBelowSiteRoot() . ' should be a file,' . ' but is of unknown type, probably because an upper level directory does not exist. Please investigate.');
         }
         return [$status];
     }
     if (!$this->isTargetCorrect()) {
         $status = new Status\ErrorStatus();
         $status->setTitle($this->getRelativePathBelowSiteRoot() . ' is a link, but link target is not as specified');
         $status->setMessage('Link target should be ' . $this->getTarget() . ' but is ' . $this->getCurrentTarget());
         return [$status];
     }
     $status = new Status\OkStatus();
     $message = 'Is a link';
     if ($this->getTarget() !== '') {
         $message .= ' and correctly points to target ' . $this->getTarget();
     }
     $status->setTitle($this->getRelativePathBelowSiteRoot());
     $status->setMessage($message);
     return [$status];
 }
Beispiel #3
0
 /**
  * Get status of directory - used in root and directory node
  *
  * @return array<\TYPO3\CMS\Install\Status\StatusInterface>
  */
 protected function getSelfStatus()
 {
     $result = array();
     if (!$this->isDirectory()) {
         $status = new Status\ErrorStatus();
         $status->setTitle($this->getRelativePathBelowSiteRoot() . ' is not a directory');
         $status->setMessage('Directory ' . $this->getRelativePathBelowSiteRoot() . ' should be a directory,' . ' but is of type ' . filetype($this->getAbsolutePath()));
         $result[] = $status;
     } elseif (!$this->isWritable()) {
         $status = new Status\ErrorStatus();
         $status->setTitle('Directory ' . $this->getRelativePathBelowSiteRoot() . ' is not writable');
         $status->setMessage('Path ' . $this->getAbsolutePath() . ' exists, but no file underneath it' . ' can be created.');
         $result[] = $status;
     } elseif (!$this->isPermissionCorrect()) {
         $status = new Status\NoticeStatus();
         $status->setTitle('Directory ' . $this->getRelativePathBelowSiteRoot() . ' permissions mismatch');
         $status->setMessage('Default configured permissions are ' . $this->getTargetPermission() . ' but current permissions are ' . $this->getCurrentPermission());
         $result[] = $status;
     } else {
         $status = new Status\OkStatus();
         $status->setTitle('Directory ' . $this->getRelativePathBelowSiteRoot());
         $status->setMessage('Is a directory with the configured permissions of ' . $this->getTargetPermission());
         $result[] = $status;
     }
     return $result;
 }
 /**
  * Checks the character set of the database and reports an error if it is not utf-8.
  *
  * @return Status\StatusInterface
  */
 protected function checkMysqlDatabaseUtf8Status()
 {
     $result = $this->getDatabaseConnection()->admin_query('SHOW VARIABLES LIKE "character_set_database"');
     $row = $this->getDatabaseConnection()->sql_fetch_assoc($result);
     $key = $row['Variable_name'];
     $value = $row['Value'];
     if ($key !== 'character_set_database') {
         $status = new Status\ErrorStatus();
         $status->setTitle('MySQL database character set check failed');
         $status->setMessage('Checking database character set failed, got key "' . $key . '" instead of "character_set_database"');
     }
     // also allow utf8mb4
     if (substr($value, 0, 4) !== 'utf8') {
         $status = new Status\ErrorStatus();
         $status->setTitle('MySQL database character set wrong');
         $status->setMessage('Your database uses character set "' . $value . '", but only "utf8" is supported with TYPO3.');
     } else {
         $status = new Status\OkStatus();
         $status->setTitle('Your database uses utf-8. All good.');
     }
     return $status;
 }
 /**
  * Check minimum MySQL version
  *
  * @return Status\StatusInterface
  */
 protected function checkMysqlVersion()
 {
     $minimumMysqlVersion = '5.5.0';
     $currentMysqlVersion = '';
     $resource = $this->getDatabaseConnection()->sql_query('SHOW VARIABLES LIKE \'version\';');
     if ($resource !== false) {
         $result = $this->getDatabaseConnection()->sql_fetch_row($resource);
         if (isset($result[1])) {
             $currentMysqlVersion = $result[1];
         }
     }
     if (version_compare($currentMysqlVersion, $minimumMysqlVersion) < 0) {
         $status = new Status\ErrorStatus();
         $status->setTitle('MySQL version too low');
         $status->setMessage('Your MySQL version ' . $currentMysqlVersion . ' is too old. TYPO3 CMS does not run' . ' with this version. Update to at least MySQL ' . $minimumMysqlVersion);
     } else {
         $status = new Status\OkStatus();
         $status->setTitle('MySQL version is fine');
     }
     return $status;
 }
Beispiel #6
0
 /**
  * Check for bug in libxml
  *
  * @return Status\StatusInterface
  */
 protected function checkLibXmlBug()
 {
     $sampleArray = array('Test>><<Data');
     $xmlContent = '<numIndex index="0">Test&gt;&gt;&lt;&lt;Data</numIndex>' . LF;
     $xml = \TYPO3\CMS\Core\Utility\GeneralUtility::array2xml($sampleArray, '', -1);
     if ($xmlContent !== $xml) {
         $status = new Status\ErrorStatus();
         $status->setTitle('PHP libxml bug present');
         $status->setMessage('Some hosts have problems saving ">><<" in a flexform.' . ' To fix this, enable [BE][flexformForceCDATA] in' . ' All Configuration.');
     } else {
         $status = new Status\OkStatus();
         $status->setTitle('PHP libxml bug not present');
     }
     return $status;
 }
Beispiel #7
0
 /**
  * Sets content of file to target content
  *
  * @throws Exception If file does not exist
  * @return \TYPO3\CMS\Install\Status\StatusInterface
  */
 protected function setContent()
 {
     $absolutePath = $this->getAbsolutePath();
     if (is_link($absolutePath) || !is_file($absolutePath)) {
         throw new Exception('File ' . $absolutePath . ' must exist', 1367060201);
     }
     if (is_null($this->targetContent)) {
         throw new Exception('Target content not defined for ' . $absolutePath, 1367060202);
     }
     $result = @file_put_contents($absolutePath, $this->targetContent);
     if ($result !== false) {
         $status = new Status\OkStatus();
         $status->setTitle('Set content to ' . $this->getRelativePathBelowSiteRoot());
     } else {
         $status = new Status\ErrorStatus();
         $status->setTitle('Setting content to ' . $this->getRelativePathBelowSiteRoot() . ' failed');
         $status->setMessage('Setting content of the file failed for unknown reasons.');
     }
     return $status;
 }
Beispiel #8
0
 /**
  * Checks the character set of the database and reports an error if it is not utf-8.
  *
  * @param Connection $connection to the database to be checked
  * @return Status\StatusInterface
  */
 protected function checkMysqlDatabaseUtf8Status(Connection $connection)
 {
     /** @var QueryBuilder $queryBuilder */
     $queryBuilder = $connection->createQueryBuilder();
     $defaultDatabaseCharset = (string) $queryBuilder->select('DEFAULT_CHARACTER_SET_NAME')->from('information_schema.SCHEMATA')->where($queryBuilder->expr()->eq('SCHEMA_NAME', $queryBuilder->createNamedParameter($connection->getDatabase(), \PDO::PARAM_STR)))->setMaxResults(1)->execute()->fetchColumn();
     // also allow utf8mb4
     if (strpos($defaultDatabaseCharset, 'utf8') !== 0) {
         $status = new Status\ErrorStatus();
         $status->setTitle('MySQL database character set check failed');
         $status->setMessage('Checking database character set failed, got key "' . $defaultDatabaseCharset . '" instead of "utf8" or "utf8mb4"');
     } else {
         $status = new Status\OkStatus();
         $status->setTitle('Your database uses utf-8. All good.');
     }
     return $status;
 }
Beispiel #9
0
 /**
  * Check register globals
  *
  * @return Status\StatusInterface
  */
 protected function checkRegisterGlobals()
 {
     $registerGlobalsEnabled = filter_var(ini_get('register_globals'), FILTER_VALIDATE_BOOLEAN, array(FILTER_REQUIRE_SCALAR, FILTER_NULL_ON_FAILURE));
     if ($registerGlobalsEnabled === true) {
         $status = new Status\ErrorStatus();
         $status->setTitle('PHP register globals on');
         $status->setMessage('register_globals=' . ini_get('register_globals') . LF . 'TYPO3 requires PHP setting "register_globals" set to off.' . ' This ancient PHP setting is a big security problem and should' . ' never be enabled:' . LF . 'register_globals=Off');
     } else {
         $status = new Status\OkStatus();
         $status->setTitle('PHP register globals off');
     }
     return $status;
 }