]> source.dussan.org Git - nextcloud-server.git/commitdiff
Do not allow installing on MySQL 8.0+ and MariaDB 10.4+ 19328/head
authorJoas Schilling <coding@schilljs.com>
Fri, 6 Mar 2020 15:09:17 +0000 (16:09 +0100)
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Tue, 14 Apr 2020 09:02:14 +0000 (11:02 +0200)
Signed-off-by: Joas Schilling <coding@schilljs.com>
lib/private/Setup/MySQL.php

index c125619f6d3c03c098f7d882d88b169b71acb7b3..0d180796986c89feef08a61fece3407a71e6b351 100644 (file)
  */
 namespace OC\Setup;
 
+use OC\DatabaseSetupException;
 use OC\DB\MySqlTools;
 use OCP\IDBConnection;
 use OCP\ILogger;
-use Doctrine\DBAL\Platforms\MySQL80Platform;
 
 class MySQL extends AbstractDatabase {
        public $dbprettyname = 'MySQL/MariaDB';
@@ -41,6 +41,20 @@ class MySQL extends AbstractDatabase {
                //check if the database user has admin right
                $connection = $this->connect(['dbname' => null]);
 
+               $result = $connection->query('SHOW VARIABLES LIKE "version" ;');
+               $row = $result->fetch();
+               $version = strtolower($row['Value']);
+
+               if (strpos($version, 'mariadb') !== false) {
+                       if (version_compare($version, '10.4', '>=')) {
+                               throw new DatabaseSetupException(sprintf('Unsupported MariaDB version %s, Nextcloud 16 requires a version lower than 10.4', $row['Value']));
+                       }
+               } {
+                       if (version_compare($version, '8', '>=')) {
+                               throw new DatabaseSetupException(sprintf('Unsupported MySQL version %s, Nextcloud 16 requires a version lower than 8.0', $row['Value']));
+                       }
+               }
+
                // detect mb4
                $tools = new MySqlTools();
                if ($tools->supports4ByteCharset($connection)) {
@@ -112,17 +126,10 @@ class MySQL extends AbstractDatabase {
                        // we need to create 2 accounts, one for global use and one for local user. if we don't specify the local one,
                        // the anonymous user would take precedence when there is one.
 
-                       if ($connection->getDatabasePlatform() instanceof Mysql80Platform) {
-                               $query = "CREATE USER '$name'@'localhost' IDENTIFIED WITH mysql_native_password BY '$password'";
-                               $connection->executeUpdate($query);
-                               $query = "CREATE USER '$name'@'%' IDENTIFIED WITH mysql_native_password BY '$password'";
-                               $connection->executeUpdate($query);
-                       } else {
-                               $query = "CREATE USER '$name'@'localhost' IDENTIFIED BY '$password'";
-                               $connection->executeUpdate($query);
-                               $query = "CREATE USER '$name'@'%' IDENTIFIED BY '$password'";
-                               $connection->executeUpdate($query);
-                       }
+                       $query = "CREATE USER '$name'@'localhost' IDENTIFIED BY '$password'";
+                       $connection->executeUpdate($query);
+                       $query = "CREATE USER '$name'@'%' IDENTIFIED BY '$password'";
+                       $connection->executeUpdate($query);
                }
                catch (\Exception $ex){
                        $this->logger->logException($ex, [