Mason data cleaning results in array error

Hi there!

I was looking for a custom page to manage GnuPG keys and I’ve found the way to do that on the Best Practical github:

The page works fine and is doing it’s job but I was unable to add the child “Admin/Tools/GnuPG” menu in
Admin/Tools Menu, so i always have to manually type the full address https://myrt.com/Admin/Tools/GnuPG.html.

I followed all the steps described on Github to add the child menu but whenever I clear the mason_data /obj/ to load it I get the following error after restarting the web server:

[28752] [Wed Nov 18 19:49:45 2020] [error]: Not an ARRAY reference at /opt/rt5/share/html/Elements/Tabs line 618.
Stack:
[/opt/rt5/share/html/Elements/Tabs:618]
[/opt/rt5/share/html/Admin/index.html:49]
[/opt/rt5/share/html/Admin/autohandler:49]
[/opt/rt5/sbin/…/lib/RT/Interface/Web.pm:710]
[/opt/rt5/sbin/…/lib/RT/Interface/Web.pm:389]
[/opt/rt5/share/html/autohandler:53] (/opt/rt5/sbin/…/lib/RT/Interface/Web/Handler.pm:209)

Any ideas about this error?

If you’re on RT5 and that branch is for RT4 it wouldn’t surprise me too much that some stuff like menu changes aren’t compatible.

If you do some digging into the code where the error is occurring we may be able to figure out what needs to change

Thanks for the quick response!

These are the lines i added to the share/html/Elements/Tabs file:

if ( RT->Config->Get('GnuPG')->{'Enable'}
    && $session{'CurrentUser'}->HasRight( Right => 'SuperUser', Object => RT->System ) )
{
    $admin_tools->child(
        'gnupg'     => title => loc('Manage GnuPG Keys'),
        description => loc('Manage GnuPG keys'),
        path        => '/Admin/Tools/GnuPG.html',
    );
}

This is the problem line from the same file, as described in the log

616      my $recents = $tickets->child( recent => title => loc('Recently Viewed'));
617      for ($session{CurrentUser}->RecentlyViewedTickets) {
**618          my ($ticketId, $timestamp) = @$_;**
619          my $ticket = RT::Ticket->new($session{CurrentUser});
620          $ticket->Load($ticketId);
621          if ($ticket->Id) {
622              my $title = $ticket->Subject || loc("(No subject)");
623              if (length $title > 50) {
624                  $title = substr($title, 0, 47);
625                  $title =~ s/\s+$//;
626                  $title .= "...";
627              }
628              $title = "#$ticketId: " . $title;
629              $recents->child( "$ticketId" => title => $title, path => "/Ticket/Display.html?id=" . $ticket->Id );
630          }
631      }

How did you apply this patch?

Just by including these lines on the file manually.

Again, the page works fine by directly looking for the URL, but the new menu child doesn’t appear and when I try to access RT after cleaning mason cache i get this error.

You put the menu code in share/html/Elements/tabs? The menu code was moved in RT5 to lib/RT/Interface/Web/MenuBuilder.pm you can try putting the menu code around line 1276 I think

1 Like

And don’t forget to do this on a local copy of the code in the /opt/rt5/local directory hierarchy, not the stuff in /opt/rt5/lib or /opt/rt5/share directly. That way it won’t be blown away if you subsequently do an RT upgrade in place.

1 Like

It worked!

I apologize for those silly questions, I’m a beginner in RT administration. This forum is greatly helpful to newbies like me!

Thanks a lot!