Search panels do not display custom module labels deployed from Module Builder package

I have a bunch of modules that belong to a package I created in Module Builder on a SuiteCRM instance (currently 7.12.6) that I have been upgrading along the way for years.

When I do a search, if there’s a hit in one of those modules I get ‘moduleKey_moduleName’ (e.g. sctrl_site for a ‘Site’ module that is part of a package with ‘sctrl’ as the Key).

Is there a fix for this? I see an open issue on https://github.com/salesagility/SuiteCRM/issues/4291 that looks like it might be related but I’m not sure.

Thanks!

I don’t think it’s related to that issue on GitHub because in your case it’s a custom module. So the names are surely not something that was in the codebase and got removed.

But then I don’t what the bug could be …

Is there a particular file where the ‘display label’ for search result headers are pulled?

As I mentioned, this installation has been upgraded through a multitude of SuiteCRM versions so it’s possible a file wasn’t generated due to a bug in a previous version. Previously I had fixed this issue in upgrade-unsafe ways and so now that I’ve upgraded to 7.12.6 recently the problem has resurfaced.

Thanks!

Non-upgrade-safe fixes aren’t very recommendable, but if you do need to do them, the basic care is to keep a list of all of them so you can re-apply when needed… and check that list after every upgrade.

I don’t know in which file that can be found, sorry… if you use your browser’s web tools, network console, to see which web request produces that final search page where the label is missing, you might be able to investigate.

I also recommend a few repairs from Admin / Repairs. Try the QR & R, and also anything related to languages or relationships.

I’ve done some digging and added some debug statements and I think I’m starting to find my way to the problem but I figured I’d reach out to see if anyone could help me along.

In ./lib/Search/UI/templates/search.results.tpl is see:

    {foreach from=$resultsAsBean item=beans key=module}
    <h3>{$module}</h3>
    <table class="list view">
        <thead>
            <tr>

so it looks like it’s iterating through $resultsAsBean and using $module as the name presented in the results.

It looks like $resultsAsBean gets assigned in ./lib/Search/UI/SearchResultsController.php in the display() function:

try {
            $smarty->assign('resultsAsBean', $this->results->getHitsAsBeans());

When I print out $this->results->getHitsAsBeans() to the log I can see that within the ‘beans’ there is absolutely no inclusion of the custom module label (‘Site’ in my case) but only the moduleKey_moduleName formatting.

If I print out the Beans that are fetched earlier within SearchResultsController.php in the getListViewHeaders() function I see the same lack of a custom module label. Those beans are generated from the line:

$bean = BeanFactory::getBean($module);

So that’s telling me that something within the Bean factory either isn’t going and grabbing the custom module labels or it’s trying to grab the labels, failing, and falling back to displaying the not-for-display name. I’m going to dig into that now but I’m hoping someone can point me in the right direction or tell me I’m barking up the wrong tree.

Thanks!

Another clue: if I add Project Tasks to the searchable modules and then get a hit for a Project Task on a search then the header for Project Task is ’ AM_TaskTemplates’.

It looks like it’s pulling the module name instead of the module label when doing a search.

And with that I was able to see that this issue was the same as https://github.com/salesagility/SuiteCRM/issues/9713

Changing

<h3>{$module}</h3>

to

<h3>{sugar_translate label='LBL_MODULE_NAME' module=$module}</h3>

in lib/Search/UI/templates/search.results.tpl

as shown in the commit seems to have fixed the issue.

1 Like

Nice detective work :male_detective: