Skip to content

Commit 4740f9b

Browse files
committed
fix: add handling for MD5 on new MySQL and deprecate MD5 SQL function
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent d40971c commit 4740f9b

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

lib/private/Setup/MySQL.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@ public function setupDatabase(): void {
3030
$connection = $this->connect(['dbname' => null]);
3131
}
3232

33+
// for MD5 support
34+
if ($connection->getDatabasePlatform() instanceof MySQL84Platform) {
35+
$statement = $connection->prepare("SHOW VARIABLES LIKE 'version';");
36+
$result = $statement->executeQuery();
37+
$row = $result->fetchAssociative();
38+
$version = $row['Value'];
39+
[$major, ] = explode('.', strtolower($version));
40+
if ((int)$major >= 9) {
41+
$statement = $connection->prepare("INSTALL COMPONENT 'file://component_classic_hashing';");
42+
$statement->executeStatement();
43+
}
44+
}
45+
3346
if ($this->tryCreateDbUser) {
3447
$this->createSpecificUser('oc_admin', new ConnectionAdapter($connection));
3548
}
@@ -103,12 +116,6 @@ private function createDBUser(IDBConnection $connection): void {
103116
$connection->executeStatement($query, [$name,$password]);
104117
$query = "CREATE USER ?@'%' IDENTIFIED WITH caching_sha2_password BY ?";
105118
$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]);
112119
} else {
113120
$query = "CREATE USER ?@'localhost' IDENTIFIED BY ?";
114121
$connection->executeStatement($query, [$name,$password]);

lib/public/DB/QueryBuilder/IFunctionBuilder.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ interface IFunctionBuilder {
2020
*
2121
* @return IQueryFunction
2222
* @since 12.0.0
23+
* @deprecated 35.0.0 - MD5 is not considered secure anymore, thus most databases have or will drop support for this function
2324
*/
2425
public function md5($input): IQueryFunction;
2526

0 commit comments

Comments
 (0)