‪TYPO3CMS  9.5
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 
24 
37 {
41  protected ‪$messageQueue;
42 
48  protected ‪$minimumPostgreSQLVerion = '9.2';
49 
54  protected ‪$minimumLibPQVersion = '9.0';
55 
63  public function ‪getStatus(): ‪FlashMessageQueue
64  {
65  $this->messageQueue = new ‪FlashMessageQueue('install');
66  $defaultConnection = GeneralUtility::makeInstance(ConnectionPool::class)
67  ->getConnectionByName(‪ConnectionPool::DEFAULT_CONNECTION_NAME);
68  if (strpos($defaultConnection->getServerVersion(), 'PostgreSQL') !== 0) {
70  }
71 
72  $this->‪checkPostgreSqlVersion($defaultConnection);
73  $this->‪checkLibpqVersion();
75  }
76 
82  protected function ‪checkPostgreSqlVersion(‪Connection $connection)
83  {
84  preg_match('/PostgreSQL ((\d+\.)*(\d+\.)*\d+)/', $connection->‪getServerVersion(), $match);
85  $currentPostgreSqlVersion = $match[1];
86  if (version_compare($currentPostgreSqlVersion, $this->minimumPostgreSQLVerion, '<')) {
87  $this->messageQueue->enqueue(new ‪FlashMessage(
88  'Your PostgreSQL version ' . $currentPostgreSqlVersion . ' is not supported. TYPO3 CMS does not run'
89  . ' with this version. The minimum supported PostgreSQL version is ' . $this->minimumPostgreSQLVerion,
90  'PostgreSQL Server version is unsupported',
92  ));
93  } else {
94  $this->messageQueue->enqueue(new ‪FlashMessage(
95  '',
96  'PostgreSQL Server version is supported'
97  ));
98  }
99  }
100 
104  protected function ‪checkLibpqVersion()
105  {
106  if (!defined('PGSQL_LIBPQ_VERSION_STR')) {
107  $this->messageQueue->enqueue(new ‪FlashMessage(
108  'It is not possible to retrieve your PostgreSQL libpq version. Please check the version'
109  . ' in the "phpinfo" area of the "System environment" module in the install tool manually.'
110  . ' This should be found in section "pdo_pgsql".'
111  . ' You should have at least the following version of PostgreSQL libpq installed: '
112  . $this->minimumLibPQVersion,
113  'PostgreSQL libpq version cannot be determined',
115  ));
116  } else {
117  preg_match('/PostgreSQL ((\d+\.)*(\d+\.)*\d+)/', \PGSQL_LIBPQ_VERSION_STR, $match);
118  $currentPostgreSqlLibpqVersion = $match[1];
119 
120  if (version_compare($currentPostgreSqlLibpqVersion, $this->minimumLibPQVersion, '<')) {
121  $this->messageQueue->enqueue(new ‪FlashMessage(
122  'Your PostgreSQL libpq version "' . $currentPostgreSqlLibpqVersion . '" is unsupported.'
123  . ' TYPO3 CMS does not run with this version. The minimum supported libpq version is '
124  . $this->minimumLibPQVersion,
125  'PostgreSQL libpq version is unsupported',
127  ));
128  } else {
129  $this->messageQueue->enqueue(new ‪FlashMessage(
130  '',
131  'PostgreSQL libpq version is supported'
132  ));
133  }
134  }
135  }
136 }
‪TYPO3\CMS\Install\SystemEnvironment\DatabasePlatform\PostgreSqlCheck\$minimumPostgreSQLVerion
‪string $minimumPostgreSQLVerion
Definition: PostgreSqlCheck.php:46
‪TYPO3\CMS\Install\SystemEnvironment\CheckInterface
Definition: CheckInterface.php:31
‪TYPO3\CMS\Install\SystemEnvironment\DatabasePlatform\PostgreSqlCheck\$minimumLibPQVersion
‪string $minimumLibPQVersion
Definition: PostgreSqlCheck.php:51
‪TYPO3\CMS\Install\SystemEnvironment\DatabasePlatform
Definition: MySqlCheck.php:3
‪TYPO3\CMS\Install\SystemEnvironment\DatabasePlatform\PostgreSqlCheck\$messageQueue
‪FlashMessageQueue $messageQueue
Definition: PostgreSqlCheck.php:40
‪TYPO3\CMS\Install\SystemEnvironment\DatabasePlatform\PostgreSqlCheck\checkLibpqVersion
‪checkLibpqVersion()
Definition: PostgreSqlCheck.php:101
‪TYPO3\CMS\Install\SystemEnvironment\DatabasePlatform\PostgreSqlCheck
Definition: PostgreSqlCheck.php:37
‪TYPO3\CMS\Install\SystemEnvironment\DatabasePlatform\PostgreSqlCheck\checkPostgreSqlVersion
‪checkPostgreSqlVersion(Connection $connection)
Definition: PostgreSqlCheck.php:79
‪TYPO3\CMS\Core\Database\ConnectionPool\DEFAULT_CONNECTION_NAME
‪const DEFAULT_CONNECTION_NAME
Definition: ConnectionPool.php:48
‪TYPO3\CMS\Core\Messaging\AbstractMessage\WARNING
‪const WARNING
Definition: AbstractMessage.php:28
‪TYPO3\CMS\Core\Database\Connection\getServerVersion
‪string getServerVersion()
Definition: Connection.php:370
‪TYPO3\CMS\Install\SystemEnvironment\DatabasePlatform\PostgreSqlCheck\getStatus
‪FlashMessageQueue getStatus()
Definition: PostgreSqlCheck.php:60
‪TYPO3\CMS\Core\Database\Connection
Definition: Connection.php:31
‪TYPO3\CMS\Core\Messaging\FlashMessage
Definition: FlashMessage.php:22
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:44
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Core\Messaging\FlashMessageQueue
Definition: FlashMessageQueue.php:25
‪TYPO3\CMS\Core\Messaging\AbstractMessage\ERROR
‪const ERROR
Definition: AbstractMessage.php:29