问题描述
我的 OTRS 系统出现此错误,我无法弄清楚发生了什么。
系统日志错误:
在执行 Execute() 时出错 Kernel::System::Console::Command::Maint::Ticket::PendingCheck: 参考发现平均大小的列表预期在 /opt/otrs/Kernel/System/GenericAgent.pm 第 988 行。
有问题的部分代码:
# add note if wanted
if ( $Param{Config}->{New}->{Note}->{Body} || $Param{Config}->{New}->{NoteBody} ) {
if ( $Self->{NoticeSTDOUT} ) {
print " - Add note to Ticket $Ticket\n";
}
my %Ticket = $Ticketobject->TicketGet(
TicketID => $Param{TicketID},DynamicFields => 0,);
if ( IsHashRefWithData( \%Ticket ) ) {
my %CustomerUserData = {}; # heres the line 988
if ( IsstringWithData( $Ticket{CustomerUserID} ) ) {
%CustomerUserData = $Kernel::OM->Get('Kernel::System::CustomerUser')->CustomerUserDataGet(
User => $Ticket{CustomerUserID},);
}
解决方法
您看到的消息是警告,而不是错误。如果您添加 use diagnostics;
,您将获得有关该问题的更多详细信息:
(W misc) You gave a single reference where Perl was expecting a list
with an even number of elements (for assignment to a hash). This
usually means that you used the anon hash constructor when you meant
to use parens. In any case,a hash requires key/value pairs.
%hash = { one => 1,two => 2,}; # WRONG
%hash = [ qw/ an anon array / ]; # WRONG
%hash = ( one => 1,); # right
%hash = qw( one 1 two 2 ); # also fine
为避免警告,您可以更改:
my %CustomerUserData = {}; # heres the line 988
到:
my %CustomerUserData;