Ссылка найдена там, где ожидался список четного размера - проблема с OTRS

Я получаю эту ошибку в своей системе 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},
            );
        }

person firewallcj    schedule 26.05.2021    source источник


Ответы (1)


Сообщение, которое вы видите, является предупреждением, а не ошибкой. Если вы добавите 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

to:

my %CustomerUserData;
person toolic    schedule 26.05.2021