|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* @copyright Copyright (c) 2021 Morris Jobke <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* @author Morris Jobke <[email protected]> |
|
9
|
|
|
* |
|
10
|
|
|
* @license GNU AGPL version 3 or any later version |
|
11
|
|
|
* |
|
12
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
13
|
|
|
* it under the terms of the GNU Affero General Public License as |
|
14
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
15
|
|
|
* License, or (at your option) any later version. |
|
16
|
|
|
* |
|
17
|
|
|
* This program is distributed in the hope that it will be useful, |
|
18
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20
|
|
|
* GNU Affero General Public License for more details. |
|
21
|
|
|
* |
|
22
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
23
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
24
|
|
|
* |
|
25
|
|
|
*/ |
|
26
|
|
|
|
|
27
|
|
|
namespace OCA\Settings\SetupChecks; |
|
28
|
|
|
|
|
29
|
|
|
use Doctrine\DBAL\Platforms\MariaDb1027Platform; |
|
30
|
|
|
use Doctrine\DBAL\Platforms\MySQL57Platform; |
|
31
|
|
|
use Doctrine\DBAL\Platforms\MySQL80Platform; |
|
32
|
|
|
use Doctrine\DBAL\Platforms\MySqlPlatform; |
|
33
|
|
|
use Doctrine\DBAL\Platforms\OraclePlatform; |
|
34
|
|
|
use Doctrine\DBAL\Platforms\PostgreSQL100Platform; |
|
35
|
|
|
use Doctrine\DBAL\Platforms\PostgreSQL94Platform; |
|
36
|
|
|
use Doctrine\DBAL\Platforms\SqlitePlatform; |
|
37
|
|
|
use OCP\IDBConnection; |
|
38
|
|
|
use OCP\IL10N; |
|
39
|
|
|
|
|
40
|
|
|
class SupportedDatabase { |
|
41
|
|
|
/** @var IL10N */ |
|
42
|
|
|
private $l10n; |
|
43
|
|
|
/** @var IDBConnection */ |
|
44
|
|
|
private $connection; |
|
45
|
|
|
|
|
46
|
|
|
private $checked = false; |
|
47
|
|
|
private $description = ''; |
|
48
|
|
|
|
|
49
|
|
|
public function __construct(IL10N $l10n, IDBConnection $connection) { |
|
50
|
|
|
$this->l10n = $l10n; |
|
51
|
|
|
$this->connection = $connection; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function check() { |
|
55
|
|
|
if ($this->checked === true) { |
|
56
|
|
|
return; |
|
57
|
|
|
} |
|
58
|
|
|
$this->checked = true; |
|
59
|
|
|
|
|
60
|
|
|
switch (get_class($this->connection->getDatabasePlatform())) { |
|
61
|
|
|
case MySQL80Platform::class: # extends MySQL57Platform |
|
62
|
|
|
case MySQL57Platform::class: # extends MySQLPlatform |
|
63
|
|
|
case MariaDb1027Platform::class: # extends MySQLPlatform |
|
64
|
|
|
case MySqlPlatform::class: |
|
65
|
|
|
$result = $this->connection->prepare('SHOW VARIABLES LIKE "version";'); |
|
66
|
|
|
$result->execute(); |
|
67
|
|
|
$row = $result->fetch(); |
|
68
|
|
|
$version = strtolower($row['Value']); |
|
69
|
|
|
|
|
70
|
|
|
if (strpos($version, 'mariadb') !== false) { |
|
71
|
|
|
if (version_compare($version, '10.2', '<')) { |
|
72
|
|
|
$this->description = $this->l10n->t('MariaDB version "%s" is used. Nextcloud 21 will no longer support this version and requires MariaDB 10.2 or higher.', $row['Value']); |
|
73
|
|
|
return; |
|
74
|
|
|
} |
|
75
|
|
|
} else { |
|
76
|
|
|
if (version_compare($version, '8', '<')) { |
|
77
|
|
|
$this->description = $this->l10n->t('MySQL version "%s" is used. Nextcloud 21 will no longer support this version and requires MySQL 8 or higher.', $row['Value']); |
|
78
|
|
|
return; |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
break; |
|
82
|
|
|
case SqlitePlatform::class: |
|
83
|
|
|
break; |
|
84
|
|
|
case PostgreSQL100Platform::class: # extends PostgreSQL94Platform |
|
85
|
|
|
case PostgreSQL94Platform::class: |
|
86
|
|
|
$result = $this->connection->prepare('SHOW server_version;'); |
|
87
|
|
|
$result->execute(); |
|
88
|
|
|
$row = $result->fetch(); |
|
89
|
|
|
if (version_compare($row['server_version'], '9.6', '<')) { |
|
90
|
|
|
$this->description = $this->l10n->t('PostgreSQL version "%s" is used. Nextcloud 21 will no longer support this version and requires PostgreSQL 9.6 or higher.', $row['server_version']); |
|
91
|
|
|
return; |
|
92
|
|
|
} |
|
93
|
|
|
break; |
|
94
|
|
|
case OraclePlatform::class: |
|
95
|
|
|
break; |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
public function description(): string { |
|
100
|
|
|
$this->check(); |
|
101
|
|
|
return $this->description; |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
public function severity(): string { |
|
105
|
|
|
return 'info'; |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
public function run(): bool { |
|
109
|
|
|
$this->check(); |
|
110
|
|
|
return $this->description === ''; |
|
111
|
|
|
} |
|
112
|
|
|
} |
|
113
|
|
|
|