From 1bfdd545d69c77d67ad0978de541a4546cd9ee87 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 4 Feb 2022 14:40:15 -0300 Subject: [PATCH] Bug 27424: Clarify logic This patch simplifies how Koha::SMTP::Servers->get_default is written, to help readability. Signed-off-by: Tomas Cohen Arazi Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi --- Koha/SMTP/Servers.pm | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Koha/SMTP/Servers.pm b/Koha/SMTP/Servers.pm index 6925c811b2..d805062e45 100644 --- a/Koha/SMTP/Servers.pm +++ b/Koha/SMTP/Servers.pm @@ -43,21 +43,21 @@ Returns the default I 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; } -- 2.39.5