|
8 | 8 |
|
9 | 9 | namespace OC\Setup; |
10 | 10 |
|
11 | | -use Doctrine\DBAL\Platforms\MySQL80Platform; |
12 | 11 | use Doctrine\DBAL\Platforms\MySQL84Platform; |
13 | 12 | use OC\DatabaseSetupException; |
14 | 13 | use OC\DB\ConnectionAdapter; |
@@ -39,6 +38,28 @@ public function setupDatabase(): void { |
39 | 38 | 'dbpassword' => $this->dbPassword, |
40 | 39 | ]); |
41 | 40 |
|
| 41 | + // for MD5 support |
| 42 | + // In MySQL 9+ MD5 has been deprecated and is only available as a component. |
| 43 | + // Until we dropped the support for it on the function builder, we need to load the component. |
| 44 | + if ($connection->getDatabasePlatform() instanceof MySQL84Platform) { |
| 45 | + $statement = $connection->prepare("SHOW VARIABLES LIKE 'version';"); |
| 46 | + $result = $statement->executeQuery(); |
| 47 | + $row = $result->fetchAssociative(); |
| 48 | + $version = $row['Value']; |
| 49 | + [$major, ] = explode('.', strtolower($version)); |
| 50 | + if ((int)$major >= 9) { |
| 51 | + // check if the component is already loaded, if not load it |
| 52 | + $statement = $connection->prepare("SELECT COUNT(*) FROM mysql.component WHERE component_urn = 'file://component_classic_hashing';"); |
| 53 | + $result = $statement->executeQuery(); |
| 54 | + $count = $result->fetchOne(); |
| 55 | + if ($count !== false && (int)$count === 0) { |
| 56 | + // not yet loaded |
| 57 | + $statement = $connection->prepare("INSTALL COMPONENT 'file://component_classic_hashing';"); |
| 58 | + $statement->executeStatement(); |
| 59 | + } |
| 60 | + } |
| 61 | + } |
| 62 | + |
42 | 63 | //create the database |
43 | 64 | $this->createDatabase($connection); |
44 | 65 |
|
@@ -103,12 +124,6 @@ private function createDBUser(IDBConnection $connection): void { |
103 | 124 | $connection->executeStatement($query, [$name,$password]); |
104 | 125 | $query = "CREATE USER ?@'%' IDENTIFIED WITH caching_sha2_password BY ?"; |
105 | 126 | $connection->executeStatement($query, [$name,$password]); |
106 | | - } elseif ($connection->getDatabasePlatform() instanceof Mysql80Platform) { |
107 | | - // TODO: Remove this elseif section as soon as MySQL 8.0 is out-of-support (after April 2026) |
108 | | - $query = "CREATE USER ?@'localhost' IDENTIFIED WITH mysql_native_password BY ?"; |
109 | | - $connection->executeStatement($query, [$name,$password]); |
110 | | - $query = "CREATE USER ?@'%' IDENTIFIED WITH mysql_native_password BY ?"; |
111 | | - $connection->executeStatement($query, [$name,$password]); |
112 | 127 | } else { |
113 | 128 | $query = "CREATE USER ?@'localhost' IDENTIFIED BY ?"; |
114 | 129 | $connection->executeStatement($query, [$name,$password]); |
|
0 commit comments