Bug 27424: Clarify logic

This patch simplifies how Koha::SMTP::Servers->get_default is written,
to help readability.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Tomás Cohen Arazi 2022-02-04 14:40:15 -03:00
parent 29c263241d
commit 1bfdd545d6
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F

View file

@ -43,21 +43,21 @@ Returns the default I<Koha::SMTP::Server> object.
sub get_default {
my ($self) = @_;
my $default;
my $default = $self->search({ is_default => 1 }, { rows => 1 })->single;
my $smtp_config = C4::Context->config('smtp_server');
unless ($default) { # no database default
my $smtp_config = C4::Context->config('smtp_server');
if ( $default = $self->search({ is_default => 1 }, { rows => 1 })->single ) {
if ( $smtp_config ) { # use koha-conf.xml
$default = Koha::SMTP::Server->new( $smtp_config );
}
else {
$default = Koha::SMTP::Server->new( $self->default_setting );
}
}
elsif ( $smtp_config ) {
$default = Koha::SMTP::Server->new( $smtp_config );
}
else {
$default = Koha::SMTP::Server->new( $self->default_setting );
$default->{_is_system_default} = 1;
}
$default->{_is_system_default} = 1;
return $default;
}