Skip to content

Commit

Permalink
Merge pull request #3398 from reosarevok/MBS-13564
Browse files Browse the repository at this point in the history
MBS-13564: Correctly override primary on alias locale change
  • Loading branch information
reosarevok authored Jan 10, 2025
2 parents 582f614 + 8c32603 commit f223f13
Show file tree
Hide file tree
Showing 2 changed files with 293 additions and 103 deletions.
13 changes: 10 additions & 3 deletions lib/MusicBrainz/Server/Data/Alias.pm
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,19 @@ sub update

# Clear existing primary for locale flag for the chosen locale
# if we are overriding them (the user chose this as primary)
if ($row{primary_for_locale}) {
# We need to load the alias because %row only contains changed values
# We need to check if either primary or the locale changed
# and then load the alias because %row only contains changed values
if ($row{primary_for_locale} || $row{locale}) {
my $alias = $self->get_by_id($alias_id);
my $locale = $row{locale} // $alias->{locale};
my $primary_for_locale = $row{primary_for_locale} // $alias->{primary_for_locale};
my $entity_id = $alias->{$type . '_id'};
$self->clear_primary_for_locale($locale, $entity_id);
# Whether we just set primary or it was already set and we
# are keeping it while changing the locale, we need to clear
# the existing primary
if ($primary_for_locale) {
$self->clear_primary_for_locale($locale, $entity_id);
}
}

add_partial_date_to_row(\%row, $alias_hash->{begin_date}, 'begin_date')
Expand Down
Loading

0 comments on commit f223f13

Please sign in to comment.