TYPO3 CMS  TYPO3_8-7
PostgreSqlCheck.php
Go to the documentation of this file.
1 <?php
2 
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
23 
34 {
40  protected $minimumPostgreSQLVerion = '9.2';
41 
46  protected $minimumLibPQVersion = '9.0';
47 
55  public function getStatus(): array
56  {
57  $statusArray = [];
58  $defaultConnection = GeneralUtility::makeInstance(ConnectionPool::class)
59  ->getConnectionByName(ConnectionPool::DEFAULT_CONNECTION_NAME);
60  if (strpos($defaultConnection->getServerVersion(), 'PostgreSQL') !== 0) {
61  return $statusArray;
62  }
63 
64  $statusArray[] = $this->checkPostgreSqlVersion($defaultConnection);
65  $statusArray[] = $this->checkLibpqVersion();
66  return $statusArray;
67  }
68 
75  protected function checkPostgreSqlVersion($connection): Status\StatusInterface
76  {
77  preg_match('/PostgreSQL ((\d+\.)*(\d+\.)*\d+)/', $connection->getServerVersion(), $match);
78  $currentPostgreSqlVersion = $match[1];
79  if (version_compare($currentPostgreSqlVersion, $this->minimumPostgreSQLVerion, '<')) {
80  $status = new Status\ErrorStatus();
81  $status->setTitle('PostgreSQL Server version is unsupported');
82  $status->setMessage(
83  'Your PostgreSQL version ' . $currentPostgreSqlVersion . ' is not supported. TYPO3 CMS does not run' .
84  ' with this version. The minimum supported PostgreSQL version is ' . $this->minimumPostgreSQLVerion
85  );
86  } else {
87  $status = new Status\OkStatus();
88  $status->setTitle('PostgreSQL Server version is supported');
89  }
90 
91  return $status;
92  }
93 
99  protected function checkLibpqVersion(): Status\StatusInterface
100  {
101  if (!defined('PGSQL_LIBPQ_VERSION_STR')) {
102  $status = new Status\WarningStatus();
103  $status->setTitle('PostgreSQL libpq version cannot be determined');
104  $status->setMessage(
105  'It is not possible to retrieve your PostgreSQL libpq version. Please check the version' .
106  ' in the "phpinfo" area of the "System environment" module in the install tool manually.' .
107  ' This should be found in section "pdo_pgsql".' .
108  ' You should have at least the following version of PostgreSQL libpq installed: ' .
109  $this->minimumLibPQVersion
110  );
111  } else {
112  preg_match('/PostgreSQL ((\d+\.)*(\d+\.)*\d+)/', \PGSQL_LIBPQ_VERSION_STR, $match);
113  $currentPostgreSqlLibpqVersion = $match[1];
114 
115  if (version_compare($currentPostgreSqlLibpqVersion, $this->minimumLibPQVersion, '<')) {
116  $status = new Status\ErrorStatus();
117  $status->setTitle('PostgreSQL libpq version is unsupported');
118  $status->setMessage(
119  'Your PostgreSQL libpq version "' . $currentPostgreSqlLibpqVersion . '" is unsupported.' .
120  ' TYPO3 CMS does not run with this version. The minimum supported libpq version is ' .
121  $this->minimumLibPQVersion
122  );
123  } else {
124  $status = new Status\OkStatus();
125  $status->setTitle('PostgreSQL libpq version is supported');
126  }
127  }
128  return $status;
129  }
130 }
static makeInstance($className,... $constructorArguments)