Completed
Push — master ( 4a399a...f98cab )
by Joas
59:07 queued 16:54
created
apps/settings/lib/SetupChecks/SupportedDatabase.php 1 patch
Indentation   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -16,106 +16,106 @@
 block discarded – undo
16 16
 
17 17
 class SupportedDatabase implements ISetupCheck {
18 18
 
19
-	private const MIN_MARIADB = '10.6';
20
-	private const MAX_MARIADB = '11.8';
21
-	private const MIN_MYSQL = '8.0';
22
-	private const MAX_MYSQL = '8.4';
23
-	private const MIN_POSTGRES = '14';
24
-	private const MAX_POSTGRES = '18';
19
+    private const MIN_MARIADB = '10.6';
20
+    private const MAX_MARIADB = '11.8';
21
+    private const MIN_MYSQL = '8.0';
22
+    private const MAX_MYSQL = '8.4';
23
+    private const MIN_POSTGRES = '14';
24
+    private const MAX_POSTGRES = '18';
25 25
 
26
-	public function __construct(
27
-		private IL10N $l10n,
28
-		private IURLGenerator $urlGenerator,
29
-		private IDBConnection $connection,
30
-	) {
31
-	}
26
+    public function __construct(
27
+        private IL10N $l10n,
28
+        private IURLGenerator $urlGenerator,
29
+        private IDBConnection $connection,
30
+    ) {
31
+    }
32 32
 
33
-	public function getCategory(): string {
34
-		return 'database';
35
-	}
33
+    public function getCategory(): string {
34
+        return 'database';
35
+    }
36 36
 
37
-	public function getName(): string {
38
-		return $this->l10n->t('Database version');
39
-	}
37
+    public function getName(): string {
38
+        return $this->l10n->t('Database version');
39
+    }
40 40
 
41
-	public function run(): SetupResult {
42
-		$databasePlatform = $this->connection->getDatabaseProvider();
43
-		if ($databasePlatform === IDBConnection::PLATFORM_MYSQL || $databasePlatform === IDBConnection::PLATFORM_MARIADB) {
44
-			$statement = $this->connection->prepare("SHOW VARIABLES LIKE 'version';");
45
-			$result = $statement->execute();
46
-			$row = $result->fetch();
47
-			$version = $row['Value'];
48
-			$versionlc = strtolower($version);
49
-			// we only care about X.Y not X.Y.Z differences
50
-			[$major, $minor, ] = explode('.', $versionlc);
51
-			$versionConcern = $major . '.' . $minor;
52
-			if (str_contains($versionlc, 'mariadb')) {
53
-				if (version_compare($versionConcern, '10.3', '=')) {
54
-					return SetupResult::info(
55
-						$this->l10n->t(
56
-							'MariaDB version 10.3 detected, this version is end-of-life and only supported as part of Ubuntu 20.04. MariaDB >=%1$s and <=%2$s is suggested for best performance, stability and functionality with this version of Nextcloud.',
57
-							[
58
-								self::MIN_MARIADB,
59
-								self::MAX_MARIADB,
60
-							]
61
-						),
62
-					);
63
-				} elseif (version_compare($versionConcern, self::MIN_MARIADB, '<') || version_compare($versionConcern, self::MAX_MARIADB, '>')) {
64
-					return SetupResult::warning(
65
-						$this->l10n->t(
66
-							'MariaDB version "%1$s" detected. MariaDB >=%2$s and <=%3$s is suggested for best performance, stability and functionality with this version of Nextcloud.',
67
-							[
68
-								$version,
69
-								self::MIN_MARIADB,
70
-								self::MAX_MARIADB,
71
-							],
72
-						),
73
-					);
74
-				}
75
-			} else {
76
-				if (version_compare($versionConcern, self::MIN_MYSQL, '<') || version_compare($versionConcern, self::MAX_MYSQL, '>')) {
77
-					return SetupResult::warning(
78
-						$this->l10n->t(
79
-							'MySQL version "%1$s" detected. MySQL >=%2$s and <=%3$s is suggested for best performance, stability and functionality with this version of Nextcloud.',
80
-							[
81
-								$version,
82
-								self::MIN_MYSQL,
83
-								self::MAX_MYSQL,
84
-							],
85
-						),
86
-					);
87
-				}
88
-			}
89
-		} elseif ($databasePlatform === IDBConnection::PLATFORM_POSTGRES) {
90
-			$statement = $this->connection->prepare('SHOW server_version;');
91
-			$result = $statement->execute();
92
-			$row = $result->fetch();
93
-			$version = $row['server_version'];
94
-			$versionlc = strtolower($version);
95
-			// we only care about X not X.Y or X.Y.Z differences
96
-			[$major, ] = explode('.', $versionlc);
97
-			$versionConcern = $major;
98
-			if (version_compare($versionConcern, self::MIN_POSTGRES, '<') || version_compare($versionConcern, self::MAX_POSTGRES, '>')) {
99
-				return SetupResult::warning(
100
-					$this->l10n->t(
101
-						'PostgreSQL version "%1$s" detected. PostgreSQL >=%2$s and <=%3$s is suggested for best performance, stability and functionality with this version of Nextcloud.',
102
-						[
103
-							$version,
104
-							self::MIN_POSTGRES,
105
-							self::MAX_POSTGRES,
106
-						])
107
-				);
108
-			}
109
-		} elseif ($databasePlatform === IDBConnection::PLATFORM_ORACLE) {
110
-			$version = 'Oracle';
111
-		} elseif ($databasePlatform === IDBConnection::PLATFORM_SQLITE) {
112
-			return SetupResult::warning(
113
-				$this->l10n->t('SQLite is currently being used as the backend database. For larger installations we recommend that you switch to a different database backend. This is particularly recommended when using the desktop client for file synchronisation. To migrate to another database use the command line tool: "occ db:convert-type".'),
114
-				$this->urlGenerator->linkToDocs('admin-db-conversion')
115
-			);
116
-		} else {
117
-			return SetupResult::error($this->l10n->t('Unknown database platform'));
118
-		}
119
-		return SetupResult::success($version);
120
-	}
41
+    public function run(): SetupResult {
42
+        $databasePlatform = $this->connection->getDatabaseProvider();
43
+        if ($databasePlatform === IDBConnection::PLATFORM_MYSQL || $databasePlatform === IDBConnection::PLATFORM_MARIADB) {
44
+            $statement = $this->connection->prepare("SHOW VARIABLES LIKE 'version';");
45
+            $result = $statement->execute();
46
+            $row = $result->fetch();
47
+            $version = $row['Value'];
48
+            $versionlc = strtolower($version);
49
+            // we only care about X.Y not X.Y.Z differences
50
+            [$major, $minor, ] = explode('.', $versionlc);
51
+            $versionConcern = $major . '.' . $minor;
52
+            if (str_contains($versionlc, 'mariadb')) {
53
+                if (version_compare($versionConcern, '10.3', '=')) {
54
+                    return SetupResult::info(
55
+                        $this->l10n->t(
56
+                            'MariaDB version 10.3 detected, this version is end-of-life and only supported as part of Ubuntu 20.04. MariaDB >=%1$s and <=%2$s is suggested for best performance, stability and functionality with this version of Nextcloud.',
57
+                            [
58
+                                self::MIN_MARIADB,
59
+                                self::MAX_MARIADB,
60
+                            ]
61
+                        ),
62
+                    );
63
+                } elseif (version_compare($versionConcern, self::MIN_MARIADB, '<') || version_compare($versionConcern, self::MAX_MARIADB, '>')) {
64
+                    return SetupResult::warning(
65
+                        $this->l10n->t(
66
+                            'MariaDB version "%1$s" detected. MariaDB >=%2$s and <=%3$s is suggested for best performance, stability and functionality with this version of Nextcloud.',
67
+                            [
68
+                                $version,
69
+                                self::MIN_MARIADB,
70
+                                self::MAX_MARIADB,
71
+                            ],
72
+                        ),
73
+                    );
74
+                }
75
+            } else {
76
+                if (version_compare($versionConcern, self::MIN_MYSQL, '<') || version_compare($versionConcern, self::MAX_MYSQL, '>')) {
77
+                    return SetupResult::warning(
78
+                        $this->l10n->t(
79
+                            'MySQL version "%1$s" detected. MySQL >=%2$s and <=%3$s is suggested for best performance, stability and functionality with this version of Nextcloud.',
80
+                            [
81
+                                $version,
82
+                                self::MIN_MYSQL,
83
+                                self::MAX_MYSQL,
84
+                            ],
85
+                        ),
86
+                    );
87
+                }
88
+            }
89
+        } elseif ($databasePlatform === IDBConnection::PLATFORM_POSTGRES) {
90
+            $statement = $this->connection->prepare('SHOW server_version;');
91
+            $result = $statement->execute();
92
+            $row = $result->fetch();
93
+            $version = $row['server_version'];
94
+            $versionlc = strtolower($version);
95
+            // we only care about X not X.Y or X.Y.Z differences
96
+            [$major, ] = explode('.', $versionlc);
97
+            $versionConcern = $major;
98
+            if (version_compare($versionConcern, self::MIN_POSTGRES, '<') || version_compare($versionConcern, self::MAX_POSTGRES, '>')) {
99
+                return SetupResult::warning(
100
+                    $this->l10n->t(
101
+                        'PostgreSQL version "%1$s" detected. PostgreSQL >=%2$s and <=%3$s is suggested for best performance, stability and functionality with this version of Nextcloud.',
102
+                        [
103
+                            $version,
104
+                            self::MIN_POSTGRES,
105
+                            self::MAX_POSTGRES,
106
+                        ])
107
+                );
108
+            }
109
+        } elseif ($databasePlatform === IDBConnection::PLATFORM_ORACLE) {
110
+            $version = 'Oracle';
111
+        } elseif ($databasePlatform === IDBConnection::PLATFORM_SQLITE) {
112
+            return SetupResult::warning(
113
+                $this->l10n->t('SQLite is currently being used as the backend database. For larger installations we recommend that you switch to a different database backend. This is particularly recommended when using the desktop client for file synchronisation. To migrate to another database use the command line tool: "occ db:convert-type".'),
114
+                $this->urlGenerator->linkToDocs('admin-db-conversion')
115
+            );
116
+        } else {
117
+            return SetupResult::error($this->l10n->t('Unknown database platform'));
118
+        }
119
+        return SetupResult::success($version);
120
+    }
121 121
 }
Please login to merge, or discard this patch.