Skip to content

Commit

Permalink
Issue #1295: tidying, do not reuse a variable name
Browse files Browse the repository at this point in the history
for different purposes
  • Loading branch information
bschmalhofer committed Oct 8, 2021
1 parent 5146f97 commit f0f97aa
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions Kernel/System/Ticket.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7380,11 +7380,12 @@ sub TicketArticleStorageSwitch {
Priority => 'error',
Message => "Need $Needed!"
);

return;
}
}

# check source vs. destination
# nothing to do when source is destination
return 1 if $Param{Source} eq $Param{Destination};

# get config object
Expand Down Expand Up @@ -7414,7 +7415,8 @@ sub TicketArticleStorageSwitch {
TicketID => $Param{TicketID},
ArticleID => $Article->{ArticleID}
)->ChannelNameGet();
next ARTICLE if $BackendName !~ /^(Email|Phone|Internal)$/;

next ARTICLE unless $BackendName =~ m/^(?:Email|Phone|Internal)$/;

my $ArticleObjectSource = Kernel::System::Ticket::Article::Backend::MIMEBase->new(
ArticleStorageModule => 'Kernel::System::Ticket::Article::Backend::MIMEBase::' . $Param{Source},
Expand All @@ -7433,7 +7435,7 @@ sub TicketArticleStorageSwitch {
}

# read source attachments
my %Index = $ArticleObjectSource->ArticleAttachmentIndex(
my %InitialSourceAttachmentIndex = $ArticleObjectSource->ArticleAttachmentIndex(
ArticleID => $Article->{ArticleID},
OnlyMyBackend => 1,
);
Expand All @@ -7454,7 +7456,7 @@ sub TicketArticleStorageSwitch {
# read source attachments
my @Attachments;
my %MD5Sums;
for my $FileID ( sort keys %Index ) {
for my $FileID ( sort keys %InitialSourceAttachmentIndex ) {
my %Attachment = $ArticleObjectSource->ArticleAttachment(
ArticleID => $Article->{ArticleID},
FileID => $FileID,
Expand Down Expand Up @@ -7489,13 +7491,13 @@ sub TicketArticleStorageSwitch {
}

# read destination attachments
%Index = $ArticleObjectDestination->ArticleAttachmentIndex(
my %DestinationAttachmentIndex = $ArticleObjectDestination->ArticleAttachmentIndex(
ArticleID => $Article->{ArticleID},
OnlyMyBackend => 1,
);

# read source attachments
if (%Index) {
if (%DestinationAttachmentIndex) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message =>
Expand Down Expand Up @@ -7543,13 +7545,13 @@ sub TicketArticleStorageSwitch {
}

# verify destination attachments
%Index = $ArticleObjectDestination->ArticleAttachmentIndex(
%DestinationAttachmentIndex = $ArticleObjectDestination->ArticleAttachmentIndex(
ArticleID => $Article->{ArticleID},
OnlyMyBackend => 1,
);
}

for my $FileID ( sort keys %Index ) {
for my $FileID ( sort keys %DestinationAttachmentIndex ) {
my %Attachment = $ArticleObjectDestination->ArticleAttachment(
ArticleID => $Article->{ArticleID},
FileID => $FileID,
Expand Down Expand Up @@ -7581,6 +7583,7 @@ sub TicketArticleStorageSwitch {

# set events
$ConfigObject->{'Ticket::EventModulePost'} = $EventConfig;

return;
}
}
Expand All @@ -7602,6 +7605,7 @@ sub TicketArticleStorageSwitch {

# set events
$ConfigObject->{'Ticket::EventModulePost'} = $EventConfig;

return;
}

Expand Down Expand Up @@ -7651,17 +7655,18 @@ sub TicketArticleStorageSwitch {
);

# read source attachments
%Index = $ArticleObjectSource->ArticleAttachmentIndex(
my %FinalSourceAttachmentIndex = $ArticleObjectSource->ArticleAttachmentIndex(
ArticleID => $Article->{ArticleID},
OnlyMyBackend => 1,
);

# read source attachments
if (%Index) {
if (%FinalSourceAttachmentIndex) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Attachments still in $Param{Source}!",
);

return;
}
}
Expand Down

0 comments on commit f0f97aa

Please sign in to comment.