Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/phpunit-pgsql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ jobs:
strategy:
matrix:
php-versions: ['8.1']
# To keep the matrix smaller we ignore PostgreSQL '11', '13', '14' as we already test 10 and 15 as lower and upper bound
postgres-versions: ['10', '15', '16']
# To keep the matrix smaller we ignore PostgreSQL '13', '14', and '15' as we already test 12 and 16 as lower and upper bound
postgres-versions: ['12', '16']
include:
- php-versions: '8.3'
postgres-versions: '15'
postgres-versions: '16'
coverage: ${{ github.event_name != 'pull_request' }}

name: PostgreSQL ${{ matrix.postgres-versions }} (PHP ${{ matrix.php-versions }}) - database tests
Expand Down
20 changes: 13 additions & 7 deletions apps/settings/lib/SetupChecks/SupportedDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,29 @@ public function run(): SetupResult {
$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;
Comment on lines +65 to +67
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

version_compare is smart enough that you do not need to do this I think.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wasn't when I tried it. It compares the full version string provided. Also I already had to be more specific for the PostgreSQL check anyway (since we only care about major and not even minor for that one).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://3v4l.org/T1lkh It works also if you do not care about minor.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's mostly for the <= check because I wanted the code to literally state the min/max "versions" (release branches) supported just as they're written in the documentation.

Comparing against N+1 feels less self documenting. ;-)

if (str_contains($versionlc, 'mariadb')) {
if (version_compare($versionlc, '10.2', '<')) {
return SetupResult::warning($this->l10n->t('MariaDB version "%s" is used. Nextcloud 21 and higher do not support this version and require MariaDB 10.2 or higher.', $version));
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));
}
} else {
if (version_compare($versionlc, '8', '<')) {
return SetupResult::warning($this->l10n->t('MySQL version "%s" is used. Nextcloud 21 and higher do not support this version and require MySQL 8.0 or MariaDB 10.2 or higher.', $version));
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));
}
}
} elseif ($databasePlatform instanceof PostgreSQLPlatform) {
$result = $this->connection->prepare('SHOW server_version;');
$result->execute();
$row = $result->fetch();
$version = $row['server_version'];
if (version_compare(strtolower($version), '9.6', '<')) {
return SetupResult::warning($this->l10n->t('PostgreSQL version "%s" is used. Nextcloud 21 and higher do not support this version and require PostgreSQL 9.6 or higher.', $version));
$versionlc = strtolower($version);
// we only care about X not X.Y or X.Y.Z differences
[$major, ] = explode('.', $versionlc);
$versionConcern = $major;
if (version_compare($versionConcern, '12', '<') || version_compare($versionConcern, '16', '>')) {
return SetupResult::warning($this->l10n->t('PostgreSQL version "%s" detected. PostgreSQL >=12 and <=16 is suggested for best performance, stability and functionality with this version of Nextcloud.', $version));
}
} elseif ($databasePlatform instanceof OraclePlatform) {
$version = 'Oracle';
Expand Down