From 18ef7aa335dc836002f58387ab5d96dfc62a0660 Mon Sep 17 00:00:00 2001 From: Erin Date: Thu, 2 May 2024 16:37:06 +0200 Subject: [PATCH 1/5] correct logic for database backup single-transaction --- src/db/mysql/Schema.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/db/mysql/Schema.php b/src/db/mysql/Schema.php index c3f829c6b2c..609d5d2698f 100644 --- a/src/db/mysql/Schema.php +++ b/src/db/mysql/Schema.php @@ -172,9 +172,10 @@ public function getDefaultBackupCommand(?array $ignoreTables = null): string $commandFromConfig = Craft::$app->getConfig()->getGeneral()->backupCommand; // https://bugs.mysql.com/bug.php?id=109685 - $useSingleTransaction = + $useSingleTransaction = !( ($isMySQL5 && version_compare($serverVersion, '5.7.41', '>=')) || - ($isMySQL8 && version_compare($serverVersion, '8.0.32', '>=')); + ($isMySQL8 && version_compare($serverVersion, '8.0.32', '>=')) + ); if ($useSingleTransaction) { $baseCommand->addArg('--single-transaction'); From d0f30af27e89408f84e1963d90dbb06d5d60e657 Mon Sep 17 00:00:00 2001 From: Erin Date: Thu, 2 May 2024 19:06:05 +0200 Subject: [PATCH 2/5] correct logic for database backup single-transaction (#14925) --- src/db/mysql/Schema.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/db/mysql/Schema.php b/src/db/mysql/Schema.php index c3f829c6b2c..609d5d2698f 100644 --- a/src/db/mysql/Schema.php +++ b/src/db/mysql/Schema.php @@ -172,9 +172,10 @@ public function getDefaultBackupCommand(?array $ignoreTables = null): string $commandFromConfig = Craft::$app->getConfig()->getGeneral()->backupCommand; // https://bugs.mysql.com/bug.php?id=109685 - $useSingleTransaction = + $useSingleTransaction = !( ($isMySQL5 && version_compare($serverVersion, '5.7.41', '>=')) || - ($isMySQL8 && version_compare($serverVersion, '8.0.32', '>=')); + ($isMySQL8 && version_compare($serverVersion, '8.0.32', '>=')) + ); if ($useSingleTransaction) { $baseCommand->addArg('--single-transaction'); From 3b42a40a11a0bf48f05542f1e92f77a38de08ccc Mon Sep 17 00:00:00 2001 From: Tim Kelty Date: Thu, 2 May 2024 13:06:29 -0400 Subject: [PATCH 3/5] Changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1703511da28..e882f16bfba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Unreleased - Fixed a bug where disclosure menus weren’t releasing their `scroll` and `resize` event listeners on hide. ([#14911](https://github.com/craftcms/cms/pull/14911]), [#14510](https://github.com/craftcms/cms/issues/14510)) +- Fixed a bug where the logic of `--single-transaction` for MySQL backups was reversed. ([#14925](https://github.com/craftcms/cms/pull/14925)) ## 4.9.0 - 2024-04-30 From ecd955e9e1037f225641c5bfaaf1b1b669c692f2 Mon Sep 17 00:00:00 2001 From: Tim Kelty Date: Thu, 2 May 2024 13:10:33 -0400 Subject: [PATCH 4/5] Simplify condition --- src/db/mysql/Schema.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/db/mysql/Schema.php b/src/db/mysql/Schema.php index 609d5d2698f..2c6eaf5fde0 100644 --- a/src/db/mysql/Schema.php +++ b/src/db/mysql/Schema.php @@ -172,10 +172,9 @@ public function getDefaultBackupCommand(?array $ignoreTables = null): string $commandFromConfig = Craft::$app->getConfig()->getGeneral()->backupCommand; // https://bugs.mysql.com/bug.php?id=109685 - $useSingleTransaction = !( - ($isMySQL5 && version_compare($serverVersion, '5.7.41', '>=')) || - ($isMySQL8 && version_compare($serverVersion, '8.0.32', '>=')) - ); + $useSingleTransaction = + ($isMySQL5 && version_compare($serverVersion, '5.7.41', '<')) || + ($isMySQL8 && version_compare($serverVersion, '8.0.32', '<')); if ($useSingleTransaction) { $baseCommand->addArg('--single-transaction'); From 86bfe0e6a9403489e973a618550e2ed9e82aa6c7 Mon Sep 17 00:00:00 2001 From: Tim Kelty Date: Thu, 2 May 2024 13:25:46 -0400 Subject: [PATCH 5/5] Changelog tweak --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e882f16bfba..09558c44c81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ## Unreleased - Fixed a bug where disclosure menus weren’t releasing their `scroll` and `resize` event listeners on hide. ([#14911](https://github.com/craftcms/cms/pull/14911]), [#14510](https://github.com/craftcms/cms/issues/14510)) -- Fixed a bug where the logic of `--single-transaction` for MySQL backups was reversed. ([#14925](https://github.com/craftcms/cms/pull/14925)) +- Fixed a bug where MySQL backups weren’t restorable on certain environments. ([#14925](https://github.com/craftcms/cms/pull/14925)) ## 4.9.0 - 2024-04-30