Skip to content

Commit

Permalink
fix(settings): Adjust SetupCheck for supported database versions
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
  • Loading branch information
susnux committed Jun 25, 2024
1 parent ea2a1ae commit f884e5d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 10 additions & 8 deletions apps/settings/lib/SetupChecks/SupportedDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,28 @@ public function run(): SetupResult {
$version = null;
$databasePlatform = $this->connection->getDatabasePlatform();
if ($databasePlatform instanceof MySQLPlatform) {
$result = $this->connection->prepare("SHOW VARIABLES LIKE 'version';");
$result->execute();
$statement = $this->connection->prepare("SHOW VARIABLES LIKE 'version';");
$result = $statement->execute();
$row = $result->fetch();
$version = $row['Value'];
$versionlc = strtolower($version);
// we only care about X.Y not X.Y.Z differences
[$major, $minor, ] = explode('.', $versionlc);
$versionConcern = $major . '.' . $minor;
if (str_contains($versionlc, 'mariadb')) {
if (version_compare($versionConcern, '10.3', '<') || version_compare($versionConcern, '10.11', '>')) {
return SetupResult::warning($this->l10n->t('MariaDB version "%s" detected. MariaDB >=10.3 and <=10.11 is suggested for best performance, stability and functionality with this version of Nextcloud.', $version));
if (version_compare($versionConcern, '10.3', '!=')) {
return SetupResult::info($this->l10n->t('MariaDB version 10.3 detected, this version is end-of-life and only supported as part of Ubuntu 20.04. MariaDB >=10.6 and <=11.4 is suggested for best performance, stability and functionality with this version of Nextcloud.'));
} elseif (version_compare($versionConcern, '10.6', '<') || version_compare($versionConcern, '11.4', '>')) {
return SetupResult::warning($this->l10n->t('MariaDB version "%s" detected. MariaDB >=10.6 and <=11.4 is suggested for best performance, stability and functionality with this version of Nextcloud.', $version));
}
} else {
if (version_compare($versionConcern, '8.0', '<') || version_compare($versionConcern, '8.3', '>')) {
return SetupResult::warning($this->l10n->t('MySQL version "%s" detected. MySQL >=8.0 and <=8.3 is suggested for best performance, stability and functionality with this version of Nextcloud.', $version));
if (version_compare($versionConcern, '8.0', '<') || version_compare($versionConcern, '8.4', '>')) {
return SetupResult::warning($this->l10n->t('MySQL version "%s" detected. MySQL >=8.0 and <=8.4 is suggested for best performance, stability and functionality with this version of Nextcloud.', $version));
}
}
} elseif ($databasePlatform instanceof PostgreSQLPlatform) {
$result = $this->connection->prepare('SHOW server_version;');
$result->execute();
$statement = $this->connection->prepare('SHOW server_version;');
$result = $statement->execute();
$row = $result->fetch();
$version = $row['server_version'];
$versionlc = strtolower($version);
Expand Down
2 changes: 1 addition & 1 deletion apps/settings/tests/SetupChecks/SupportedDatabaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function testPass(): void {
/** SQlite always gets a warning */
$this->assertEquals(SetupResult::WARNING, $this->check->run()->getSeverity());
} else {
$this->assertEquals(SetupResult::SUCCESS, $this->check->run()->getSeverity());
$this->assertContains($this->check->run()->getSeverity(), [SetupResult::SUCCESS, SetupResult::INFO]);
}
}
}

0 comments on commit f884e5d

Please sign in to comment.