Skip to content

Commit ecbb5d8

Browse files
authored
Merge pull request #61247 from nextcloud/fix/mysql
chore: bump MySQL to min 8.4 and support 9.7
2 parents 874ef1e + 43dc92d commit ecbb5d8

6 files changed

Lines changed: 52 additions & 19 deletions

File tree

.github/workflows/phpunit-mysql-sharding.yml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ jobs:
5757
fail-fast: false
5858
matrix:
5959
include:
60-
- mysql-versions: '8.0'
61-
php-versions: '8.3'
6260
- mysql-versions: '8.4'
61+
php-versions: '8.3'
62+
- mysql-versions: '9.7'
6363
php-versions: '8.5'
6464

6565
name: Sharding - MySQL ${{ matrix.mysql-versions }} (PHP ${{ matrix.php-versions }}) - database tests
@@ -72,7 +72,7 @@ jobs:
7272
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
7373

7474
mysql:
75-
image: ghcr.io/nextcloud/continuous-integration-mysql-${{ matrix.mysql-versions }}:latest # zizmor: ignore[unpinned-images]
75+
image: mysql:${{ matrix.mysql-versions }} # zizmor: ignore[unpinned-images]
7676
ports:
7777
- 4444:3306/tcp
7878
env:
@@ -82,7 +82,7 @@ jobs:
8282
MYSQL_DATABASE: oc_autotest
8383
options: --health-cmd="mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 10
8484
shard1:
85-
image: ghcr.io/nextcloud/continuous-integration-mysql-${{ matrix.mysql-versions }}:latest # zizmor: ignore[unpinned-images]
85+
image: mysql:${{ matrix.mysql-versions }} # zizmor: ignore[unpinned-images]
8686
ports:
8787
- 5001:3306/tcp
8888
env:
@@ -92,7 +92,7 @@ jobs:
9292
MYSQL_DATABASE: nextcloud
9393
options: --health-cmd="mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 10
9494
shard2:
95-
image: ghcr.io/nextcloud/continuous-integration-mysql-${{ matrix.mysql-versions }}:latest # zizmor: ignore[unpinned-images]
95+
image: mysql:${{ matrix.mysql-versions }} # zizmor: ignore[unpinned-images]
9696
ports:
9797
- 5002:3306/tcp
9898
env:
@@ -102,7 +102,7 @@ jobs:
102102
MYSQL_DATABASE: nextcloud
103103
options: --health-cmd="mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 10
104104
shard3:
105-
image: ghcr.io/nextcloud/continuous-integration-mysql-${{ matrix.mysql-versions }}:latest # zizmor: ignore[unpinned-images]
105+
image: mysql:${{ matrix.mysql-versions }} # zizmor: ignore[unpinned-images]
106106
ports:
107107
- 5003:3306/tcp
108108
env:
@@ -112,7 +112,7 @@ jobs:
112112
MYSQL_DATABASE: nextcloud
113113
options: --health-cmd="mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 10
114114
shard4:
115-
image: ghcr.io/nextcloud/continuous-integration-mysql-${{ matrix.mysql-versions }}:latest # zizmor: ignore[unpinned-images]
115+
image: mysql:${{ matrix.mysql-versions }} # zizmor: ignore[unpinned-images]
116116
ports:
117117
- 5004:3306/tcp
118118
env:
@@ -151,6 +151,13 @@ jobs:
151151
echo "SET GLOBAL sql_mode=(SELECT CONCAT(@@sql_mode,',ONLY_FULL_GROUP_BY'));" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword
152152
echo "SELECT @@sql_mode;" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword
153153
154+
- name: Enable MD5 MySQL support
155+
if: matrix.mysql-versions == '9.7'
156+
run: |
157+
for MYSQL_PORT in 4444 5001 5002 5003 5004; do
158+
echo "INSTALL COMPONENT 'file://component_classic_hashing';" | mysql -h 127.0.0.1 -P $MYSQL_PORT -u root -prootpassword
159+
done
160+
154161
- name: Set up Nextcloud
155162
env:
156163
DB_PORT: 4444

.github/workflows/phpunit-mysql.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ jobs:
6060
fail-fast: false
6161
matrix:
6262
include:
63-
- mysql-versions: '8.0'
64-
php-versions: '8.3'
6563
- mysql-versions: '8.4'
64+
php-versions: '8.3'
65+
- mysql-versions: '9.7'
6666
php-versions: '8.5'
6767

6868
name: MySQL ${{ matrix.mysql-versions }} (PHP ${{ matrix.php-versions }}) - database tests
@@ -75,7 +75,7 @@ jobs:
7575
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
7676

7777
mysql:
78-
image: ghcr.io/nextcloud/continuous-integration-mysql-${{ matrix.mysql-versions }}:latest # zizmor: ignore[unpinned-images]
78+
image: mysql:${{ matrix.mysql-versions }} # zizmor: ignore[unpinned-images]
7979
ports:
8080
- 4444:3306/tcp
8181
env:

apps/settings/lib/SetupChecks/SupportedDatabase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ class SupportedDatabase implements ISetupCheck {
1919

2020
private const MIN_MARIADB = '10.6';
2121
private const MAX_MARIADB = '11.8';
22-
private const MIN_MYSQL = '8.0';
23-
private const MAX_MYSQL = '8.4';
22+
private const MIN_MYSQL = '8.4';
23+
private const MAX_MYSQL = '9.7';
2424
private const MIN_POSTGRES = '14';
2525
private const MAX_POSTGRES = '18';
2626
private const MIN_ORACLE = '12.2';

build/psalm-baseline.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,6 +1420,11 @@
14201420
<code><![CDATA[getUsersForUserValue]]></code>
14211421
</DeprecatedMethod>
14221422
</file>
1423+
<file src="apps/files/lib/Command/RepairTree.php">
1424+
<DeprecatedMethod>
1425+
<code><![CDATA[md5]]></code>
1426+
</DeprecatedMethod>
1427+
</file>
14231428
<file src="apps/files/lib/Command/Scan.php">
14241429
<DeprecatedMethod>
14251430
<code><![CDATA[listen]]></code>
@@ -3232,6 +3237,11 @@
32323237
<code><![CDATA[$this->request->server]]></code>
32333238
</NoInterfaceProperties>
32343239
</file>
3240+
<file src="core/Migrations/Version24000Date20211230140012.php">
3241+
<DeprecatedMethod>
3242+
<code><![CDATA[md5]]></code>
3243+
</DeprecatedMethod>
3244+
</file>
32353245
<file src="core/Migrations/Version25000Date20220515204012.php">
32363246
<DeprecatedConstant>
32373247
<code><![CDATA[Types::JSON]]></code>

lib/private/Setup/MySQL.php

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
namespace OC\Setup;
1010

11-
use Doctrine\DBAL\Platforms\MySQL80Platform;
1211
use Doctrine\DBAL\Platforms\MySQL84Platform;
1312
use OC\DatabaseSetupException;
1413
use OC\DB\ConnectionAdapter;
@@ -39,6 +38,28 @@ public function setupDatabase(): void {
3938
'dbpassword' => $this->dbPassword,
4039
]);
4140

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+
4263
//create the database
4364
$this->createDatabase($connection);
4465

@@ -103,12 +124,6 @@ private function createDBUser(IDBConnection $connection): void {
103124
$connection->executeStatement($query, [$name,$password]);
104125
$query = "CREATE USER ?@'%' IDENTIFIED WITH caching_sha2_password BY ?";
105126
$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]);
112127
} else {
113128
$query = "CREATE USER ?@'localhost' IDENTIFIED BY ?";
114129
$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)