@@ -38,75 +38,75 @@ |
||
| 38 | 38 | use OCP\IL10N; |
| 39 | 39 | |
| 40 | 40 | class SupportedDatabase { |
| 41 | - /** @var IL10N */ |
|
| 42 | - private $l10n; |
|
| 43 | - /** @var IDBConnection */ |
|
| 44 | - private $connection; |
|
| 41 | + /** @var IL10N */ |
|
| 42 | + private $l10n; |
|
| 43 | + /** @var IDBConnection */ |
|
| 44 | + private $connection; |
|
| 45 | 45 | |
| 46 | - private $checked = false; |
|
| 47 | - private $description = ''; |
|
| 46 | + private $checked = false; |
|
| 47 | + private $description = ''; |
|
| 48 | 48 | |
| 49 | - public function __construct(IL10N $l10n, IDBConnection $connection) { |
|
| 50 | - $this->l10n = $l10n; |
|
| 51 | - $this->connection = $connection; |
|
| 52 | - } |
|
| 49 | + public function __construct(IL10N $l10n, IDBConnection $connection) { |
|
| 50 | + $this->l10n = $l10n; |
|
| 51 | + $this->connection = $connection; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - public function check() { |
|
| 55 | - if ($this->checked === true) { |
|
| 56 | - return; |
|
| 57 | - } |
|
| 58 | - $this->checked = true; |
|
| 54 | + public function check() { |
|
| 55 | + if ($this->checked === true) { |
|
| 56 | + return; |
|
| 57 | + } |
|
| 58 | + $this->checked = true; |
|
| 59 | 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']); |
|
| 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 | 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.0 or MariaDB 10.2 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 | - } |
|
| 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.0 or MariaDB 10.2 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 | 98 | |
| 99 | - public function description(): string { |
|
| 100 | - $this->check(); |
|
| 101 | - return $this->description; |
|
| 102 | - } |
|
| 99 | + public function description(): string { |
|
| 100 | + $this->check(); |
|
| 101 | + return $this->description; |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - public function severity(): string { |
|
| 105 | - return 'info'; |
|
| 106 | - } |
|
| 104 | + public function severity(): string { |
|
| 105 | + return 'info'; |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - public function run(): bool { |
|
| 109 | - $this->check(); |
|
| 110 | - return $this->description === ''; |
|
| 111 | - } |
|
| 108 | + public function run(): bool { |
|
| 109 | + $this->check(); |
|
| 110 | + return $this->description === ''; |
|
| 111 | + } |
|
| 112 | 112 | } |