Do not allow installing on MySQL 8.0+ and MariaDB 10.4+

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2020-03-06 16:09:17 +01:00 committed by John Molakvoæ (skjnldsv)
parent 6cdc63ff69
commit f36ba8bb01
No known key found for this signature in database
GPG Key ID: 60C25B8C072916CF
1 changed files with 19 additions and 12 deletions

View File

@ -29,10 +29,10 @@
*/
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, [