RT 5.0.0 [error]: Can't locate object method "child" via package "Menu"

Greetings RT Users
I am new to RT and have recently upgraded a 4.4.4 system left behind by my predecessor to 5.0.0 with minimal issues.

I am attempting to view an asset using the SelfService portal with an unprivileged user. I have changed “view asset”, “view catalogue”, and “view custom field values” into just about every possible combination through groups and roles.

Below is the error I get with every attempt:

[7541] [Tue Sep 29 17:48:21 2020] [error]: Can’t locate object method “child” via package “Menu” (perhaps you forgot to load “Menu”?) at /opt/rt5/sbin/…/lib/RT/Interface/Web/MenuBuilder.pm line 1642.

Stack:
[/opt/rt5/sbin/…/lib/RT/Interface/Web/MenuBuilder.pm:1642]
[/opt/rt5/share/html/Elements/Tabs:63]
[/opt/rt5/share/html/SelfService/Elements/Header:49]
[/opt/rt5/share/html/SelfService/Asset/Display.html:48]
[/opt/rt5/sbin/…/lib/RT/Interface/Web.pm:707]
[/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)

If I elevate the user to privileged, they are able to see the asset as expected but they are also able to see users and groups outside their own and this is not acceptable.

I am hoping that someone here has either run into this issue or has an idea of what I might need to do.

I am fine with the elevated permissions and interface, if I can disable the user/group view/search abilities.

Did you ever resolve this? We have the same issue. I’m GUESSING it’s a permission issue, but not sure…

negative. I am still looking as well.

Any chance you installed RT 5 in the same location as RT 4?

This is an upgrade from an rt4 instance. I haven’t had any problems with it other than this singular error and it wasn’t a gating item so I moved past, hoping to find a solution once I rounded back to that point.

I mean to ask, did you install into a new directory on the file system “/opt/rt5” or into the old “/opt/rt4” dir

new folder. I was taking over the project and wanted the data but not the configs.

So my first thought is, maybe upgrade to 5.0.2 since there are some bug fixes in the newer version. But the code that is resulting in the error doesn’t point to any obvious issues to me

Just a thought, but could you make a local copy of /opt/rt5/lib/RT/Interface/Web/MenuBuilder.pm into /opt/rt5/local/lib/RT/Interface/Web/MenuBuilder.pm and then in the local copy add the line:

use RT::Interface::Web::Menu;

under the use warnings; line. Then clear the Mason cache, give the web server a restart and see if that fixes things for you.

We face the same problem with ImDaShoe, even when upgrading from 4.4.4 to 5.0.2 (new folder opt//rt5). Any suggestions, please?

I haven’t taken either of these steps, was planning on it this coming week.

GreenJimll
March 29

had suggested the following:

Just a thought, but could you make a local copy of /opt/rt5/lib/RT/Interface/Web/MenuBuilder.pm into /opt/rt5/local/lib/RT/Interface/Web/MenuBuilder.pm and then in the local copy add the line:

use RT::Interface::Web::Menu;

under the use warnings; line. Then clear the Mason cache, give the web server a restart and see if that fixes things for you.

Unfortunately, no success. I tried ALL the above, but the error did not disappear or change…
What makes me wonder is the sbin part in the path of the file /opt/rt5/sbin/…/lib/RTInterface/Web/MenuBuilder.pm (please check 1rst message of ImDaShoe)

Might all the problem arise from neglecting the run of etc/upgrade/upgrade-assets utility??

OK, I’ve had a bit of a read of the code, and I’m not sure what the intention of


        if (Menu->child("new")) {
            my $actions = $page->child("actions", title => loc("Actions"));
            $actions->child("create-linked-ticket", title => loc("Create linked ticket"), path => "/SelfService/Asset/CreateLinkedTicket.html?Asset=$id");
        }

is supposed to be. I think its trying to make an Actions menu with a “Create linked ticket” action appear based on a condition, but the condition doesn’t seem to make sense. So, how about either:

a) commenting all four lines above out in your local copy of the code if you don’t need to create linked tickets

OR

b) comment out the outer two conditional lines from around the inner two lines so that you always get the create linked tickets action appear.

At least either of those should stop the error appearing (and you can probably get rid of the use line I suggested above too).

Actually digging a bit deeper into Best Practical’s github, it looks like that if(Menu->child("new")) { is a hang over from when the menu building logic was lifted out of share/html/Elements/Tabs and put into its own module. If you look at commit 755042f6a9941734e21a987a638ff03b36b4dc18 you can see the old code with those lines towards the end of the removed code.

Now looking up a back a bit from the problem lines in that commit, we can see:

    if ( $queue_count > 1 ) {
        Menu->child( new => title => loc('New ticket'), path => '/SelfService/CreateTicketInQueue.html' );
    } elsif ( $queue_id ) {
        Menu->child( new => title => loc('New ticket'), path => '/SelfService/Create.html?Queue=' . $queue_id );
    }

Now in 5.0.0’s lib/RT/Interface/Web/MenuBuilder.pm the equivalent lines to those are:

    if ( $queue_count > 1 ) {
        $home->child( new => title => loc('Create Ticket'), path => '/SelfService/CreateTicketInQueue.html' );
    } elsif ( $queue_id ) {
        $home->child( new => title => loc('Create Ticket'), path => '/SelfService/Create.html?Queue=' . $queue_id );
    }

So what I’m now wondering is if the naughty broken code in lib/RT/Interface/Web/MenuBuilder.pm should actually read:

        if ($home->child("new")) {
            my $actions = $page->child("actions", title => loc("Actions"));
            $actions->child("create-linked-ticket", title => loc("Create linked ticket"), path => "/SelfService/Asset/CreateLinkedTicket.html?Asset=$id");
        }

Not sure, and we don’t use assets here, so this is an “exercise for the reader” (as my maths master used to like to say when we reached a sticky bit in a calculation!).

Hey @GreenJimll thank you very much!
Both your replies lead to a solution regarding the display of Asset details!
However… the “Create Linked Ticket” button does not yet appear in any of your solutions… :frowning_face:
It remains a problem to solve…

(Let me say that I already have checked the rights: ShowAsset, ShowAssetsMenu, ModifyAsset, ShowCatalog, CreateTicket, more for the Requestor/User)

Did you submit a bug report to Best Practical about this? If not I’ll drop one in so that hopefully it gets fixed in future releases.

I’m still confused by the condition surrounding the bit to add the action link. You might try commenting that out to just leave:

#        if ($home->child("new")) {
            my $actions = $page->child("actions", title => loc("Actions"));
            $actions->child("create-linked-ticket", title => loc("Create linked ticket"), path => "/SelfService/Asset/CreateLinkedTicket.html?Asset=$id");
#        }

and then see if that gives you the required menu.

Didn’t submit a bug.
Even with your last proposed edit @GreenJimll, nothing changed!
Thanks anyway!

OK, I’ve submitted a bug report - ticket number 37377 (log in as guest to view it).

1 Like

This is now fixed in 5.0-trunk, so you could grab a patch from github. The fix is basically what @GreenJimll pointed to above.

1 Like