From 780ddc790cf4affb37462c661ade85d1f3e63747 Mon Sep 17 00:00:00 2001 From: Jonas Raoni Soares da Silva Date: Wed, 15 Nov 2023 15:03:42 +0300 Subject: [PATCH 1/2] pkp/pkp-lib#9487 Skipped non-conforming setting tables from failing the migration --- .../migration/upgrade/PKPv3_3_0UpgradeMigration.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/classes/migration/upgrade/PKPv3_3_0UpgradeMigration.php b/classes/migration/upgrade/PKPv3_3_0UpgradeMigration.php index 2cd9053afb4..1db39175b0c 100755 --- a/classes/migration/upgrade/PKPv3_3_0UpgradeMigration.php +++ b/classes/migration/upgrade/PKPv3_3_0UpgradeMigration.php @@ -16,6 +16,7 @@ use APP\core\Services; use APP\facades\Repo; +use Exception; use Illuminate\Database\PostgresConnection; use Illuminate\Database\Query\JoinClause; use Illuminate\Database\Schema\Blueprint; @@ -768,9 +769,13 @@ private function _settingsAsJSON() $this->_toJSON($row, $tableName, ['plugin_name', 'context_id', 'setting_name'], 'setting_value'); }); } elseif (Schema::hasColumn($tableName, 'setting_type')) { - DB::table($tableName)->where('setting_type', 'object')->get()->each(function ($row) use ($tableName) { - $this->_toJSON($row, $tableName, ['setting_name', 'locale'], 'setting_value'); - }); + try { + $settings = DB::table($tableName)->where('setting_type', 'object')->get(); + } catch (Exception $e) { + error_log("Failed to migrate the settings entity \"{$tableName}\"\n" . $e); + continue; + } + $settings->each(fn ($row) => $this->_toJSON($row, $tableName, ['setting_name', 'locale'], 'setting_value')); } } From c64eaeb2d2adbe01bfd66d0366bcecf63a06934f Mon Sep 17 00:00:00 2001 From: Jonas Raoni Soares da Silva Date: Thu, 11 Jan 2024 11:29:46 +0300 Subject: [PATCH 2/2] pkp/pkp-lib#9487 Included common fields for extra reliability --- classes/migration/upgrade/PKPv3_3_0UpgradeMigration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/migration/upgrade/PKPv3_3_0UpgradeMigration.php b/classes/migration/upgrade/PKPv3_3_0UpgradeMigration.php index 1db39175b0c..82cc0ac8dd6 100755 --- a/classes/migration/upgrade/PKPv3_3_0UpgradeMigration.php +++ b/classes/migration/upgrade/PKPv3_3_0UpgradeMigration.php @@ -770,7 +770,7 @@ private function _settingsAsJSON() }); } elseif (Schema::hasColumn($tableName, 'setting_type')) { try { - $settings = DB::table($tableName)->where('setting_type', 'object')->get(); + $settings = DB::table($tableName, 's')->where('setting_type', 'object')->get(['setting_name', 'setting_value', 's.*']); } catch (Exception $e) { error_log("Failed to migrate the settings entity \"{$tableName}\"\n" . $e); continue;