在预期大小列表的位置找到参考 - OTRS 问题

Reference found where even-sized list expected - OTRS issue

我的 OTRS 系统出现此错误,我无法弄清楚发生了什么。

系统日志错误:

There was an error executing Execute() in Kernel::System::Console::Command::Maint::Ticket::PendingCheck: Reference found where even-sized list expected at /opt/otrs/Kernel/System/GenericAgent.pm line 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, two => 2, );    # right
    %hash = qw( one 1 two 2 );                  # also fine

要避免警告,您可以更改:

my %CustomerUserData = {}; # heres the line 988

至:

my %CustomerUserData;