Skip to content

Commit

Permalink
Merge pull request #2082 from RotherOSS/issue-#2081-early_return
Browse files Browse the repository at this point in the history
Issue #2081 early return
  • Loading branch information
bschmalhofer authored Jan 6, 2023
2 parents 07c193b + 3f9b8b9 commit fb69eb1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
7 changes: 4 additions & 3 deletions Kernel/System/Ticket/Article/Backend/Base.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# OTOBO is a web-based ticketing system for service organisations.
# --
# Copyright (C) 2001-2020 OTRS AG, https://otrs.com/
# Copyright (C) 2019-2022 Rother OSS GmbH, https://otobo.de/
# Copyright (C) 2019-2023 Rother OSS GmbH, https://otobo.de/
# --
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
Expand Down Expand Up @@ -522,6 +522,7 @@ Returns:
ChangeBy => ...,
);
Returns an empty list when no article was found.
=cut

Expand All @@ -539,12 +540,12 @@ sub _MetaArticleGet {
}

# Use ArticleList() internally to benefit from its ticket-level cache.
my @MetaArticleIndex = $Kernel::OM->Get('Kernel::System::Ticket::Article')->ArticleList(
my ($FirstMetaArticle) = $Kernel::OM->Get('Kernel::System::Ticket::Article')->ArticleList(
TicketID => $Param{TicketID},
ArticleID => $Param{ArticleID},
);

return %{ $MetaArticleIndex[0] // {} };
return %{ $FirstMetaArticle // {} };
}

=head2 _MetaArticleDelete()
Expand Down
5 changes: 3 additions & 2 deletions Kernel/System/Ticket/Article/Backend/Invalid.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# OTOBO is a web-based ticketing system for service organisations.
# --
# Copyright (C) 2001-2020 OTRS AG, https://otrs.com/
# Copyright (C) 2019-2022 Rother OSS GmbH, https://otobo.de/
# Copyright (C) 2019-2023 Rother OSS GmbH, https://otobo.de/
# --
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
Expand Down Expand Up @@ -98,9 +98,10 @@ sub ArticleGet {

my %MetaArticle = $Self->_MetaArticleGet(%Param);

my %ArticleSenderTypeList = $Kernel::OM->Get('Kernel::System::Ticket::Article')->ArticleSenderTypeList();
return unless %MetaArticle;

# Include sender type lookup.
my %ArticleSenderTypeList = $Kernel::OM->Get('Kernel::System::Ticket::Article')->ArticleSenderTypeList();
$MetaArticle{SenderType} = $ArticleSenderTypeList{ $MetaArticle{SenderTypeID} };

return %MetaArticle;
Expand Down
32 changes: 15 additions & 17 deletions scripts/test/DynamicField/ObjectType/Article/ObjectDataGet.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# OTOBO is a web-based ticketing system for service organisations.
# --
# Copyright (C) 2001-2020 OTRS AG, https://otrs.com/
# Copyright (C) 2019-2022 Rother OSS GmbH, https://otobo.de/
# Copyright (C) 2019-2023 Rother OSS GmbH, https://otobo.de/
# --
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
Expand All @@ -18,10 +18,13 @@ use strict;
use warnings;
use utf8;

# Set up the test driver $Self when we are running as a standalone script.
use Kernel::System::UnitTest::RegisterDriver;
# core modules

use vars (qw($Self));
# CPAN modules
use Test2::V0;

# OTOBO modules
use Kernel::System::UnitTest::RegisterDriver; # Set up $Kernel::OM

# Get helper object
$Kernel::OM->ObjectParamAdd(
Expand Down Expand Up @@ -65,10 +68,7 @@ my $TicketID = $TicketObject->TicketCreate(
UserID => 1,
);

$Self->True(
$TicketID,
"TicketCreate()",
);
ok( $TicketID, "TicketCreate()" );

my $ArticleObject = $Kernel::OM->Get('Kernel::System::Ticket::Article');
my $ArticleBackendObject = $ArticleObject->BackendForChannel( ChannelName => 'Phone' );
Expand All @@ -87,10 +87,7 @@ my $ArticleID = $ArticleBackendObject->ArticleCreate(
HistoryComment => '%%',
UserID => 1,
);
$Self->True(
$ArticleID,
"ArticleCreate()",
);
ok( $ArticleID, "ArticleCreate()" );

my %ArticleData = $ArticleBackendObject->ArticleGet(
TicketID => $TicketID,
Expand Down Expand Up @@ -221,26 +218,27 @@ for my $Test (@Tests) {
my %ObjectData = $ObjectHandlerObject->ObjectDataGet( %{ $Test->{Config} } );

if ( !$Test->{Success} ) {
$Self->IsDeeply(
is(
\%ObjectData,
{},
"$Test->{Name} - ObjectDataGet() unsuccessful",
);

next TEST;
}

$Self->IsDeeply(
is(
\%ObjectData,
$Test->{ExectedResult},
"$Test->{Name} ObjectDataGet()",
);
}
continue {

# force creation of new ParamObject in the next iteration
$Kernel::OM->ObjectsDiscard(
Objects => [ 'Kernel::System::Web::Request', ],
);
}

# cleanup is done by RestoreDatabase

$Self->DoneTesting();
done_testing;

0 comments on commit fb69eb1

Please sign in to comment.