Bug 34622: Fix store default query

Exclude self smtp server from all the servers being updated to not default if self is_default

Signed-off-by: Émily-Rose Francoeur <emily-rose.francoeur@inLibro.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Pedro Amorim 2023-08-25 16:26:10 +00:00 committed by Tomas Cohen Arazi
parent 0018fe8fba
commit 6d54d2419f
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F

View file

@ -44,9 +44,9 @@ sub store {
$self->_result->result_source->schema->txn_do(
sub {
Koha::SMTP::Servers->search->update( { is_default => 0 },
{ no_triggers => 1 } )
if $self->is_default;
Koha::SMTP::Servers->search( { id => { '!=' => $self->id } } )
->update( { is_default => 0 }, { no_triggers => 1 } )
if $self->is_default;
$self = $self->SUPER::store;
}