Skip to content

Commit

Permalink
pkp#8598 Migration Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
defstat committed Feb 12, 2023
1 parent 12c0818 commit d1c60dd
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion classes/migration/upgrade/v3_4_0/MergeLocalesMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,13 @@ function updateSingleValueLocaleEmailData(string $localevalue, string $table, st
$defaultLocale = $updatedLocaleRet[$updatedLocale];

if (!is_null($defaultLocale)) {
DB::table($table)
->where('email_key', '=', $email_key)
->where('locale', '=', $localevalue)
->where('subject', '')
->where('body', '')
->delete();

if ($defaultLocale == $localevalue) {
DB::table($table)
->where('email_key', '=', $email_key)
Expand Down Expand Up @@ -344,7 +351,16 @@ function getUpdatedLocale(string $localeValue) : ?Collection

// In case there is an explicit transformation from code_XX to code_CC
if ($affectedLocales->keys()->contains($localeValue)) {
return collect([$affectedLocales->get($localeValue) => null]);
if ($affectedLocales->get($localeValue) instanceof Collection) {
// The first locale is going to be the default one
$defaultLocale = $affectedLocales->get($localeValue)->first();

// return a collection of the specific transformation as key and the default locale as value
return collect(["${localeValue}" => "${defaultLocale}"]);
} else {
return collect([$affectedLocales->get($localeValue) => null]);
}

} else { //in case there is not an explixit transformation from code_XX to code_CC
// find the two letter locale code
$localeCode = substr($localeValue, 0, 2);
Expand Down

0 comments on commit d1c60dd

Please sign in to comment.