Dear Joomla Development Team,
I'm a developer of Geek ElasticSearch component.
My component supports index and search data of Joomla core components and many 3rd party components.
It enables users to index data manually in the search component dashboard, or create a cron job to incremental index new items automatically with CLI script / command (is similar to a CLI script of Smart Search)
The CLI script in Joomla 3 was extended of CliApplication, and it was working well.
In Joomla 4, it uses the ConsoleApplication to execute CLI commands. But the ConsoleApplication does not support a method getMenu() like the AdministratorApplication (used for Backend) and the SiteApplication (used for Frontend).
So this causes an error when indexing data of some 3rd party components since the Route class of these components needs to call the getMenu() method of the Application to get their menu items and build SEF URLs.
Could you please consider adding this method to the ConsoleApplication class in the next release of Joomla 4?
Thank you.
Best regards,
Thanh Nguyen
Labels |
Added:
No Code Attached Yet
|
Labels |
Added:
Feature
|
I do not know how it can be fixed. And whether it can be fixed.
For now you can try to use work around like this:
// Keep CLI app
$cliApp = \Joomla\CMS\Factory::$application;
// Assign the Administrator application to the Factory
$adminApp = \Joomla\CMS\Factory::getContainer()->get(\Joomla\CMS\Application\AdministratorApplication::class);
\Joomla\CMS\Factory::$application = $adminApp;
// Run your code
....
....
// Restore the CLI app
\Joomla\CMS\Factory::$application = $cliApp;
Hello @Fedik,
Thank you for your reply.
I would like to provide more specific information on this issue.
As you know, Joomla supports some CLI commands that enables user to carry out maintenance tasks.
Joomla also allow developers to write more CLI commands to do particular tasks with their component.
And for our Geek ElasticSearch component, we developed a CLI application that enables users to index data of supported 3rd-party components from a command-line interface (Like the Indexer command of SmartSearch/Finder component).
When indexing data of one 3rd-party component (e.g: Kunena), it will need to call the "buildRoute" method of the Router class of Kunena component.
And in this Router class, the "buildRoute" method use the code below to get the Menu
$app = Factory::getApplication();
$menu = $app->getMenu();
But the "CliApplication" is not extended from the "CMSApplication", so it does have the method "getMenu".
And it cause this error.
I can't edit the Router class of 3rd party components to fix this issue.
So there is only way to fix this issue is that updating the "CliApplication" class to support the "getMenu" method.
I hope it provided enough information.
Thank you for your support.
Sounds more like an issue with the way kunena is written if it is reliant on the menu
Hello @brianteeman
There are many components write their Router class this way to lookup menu Itemid and build self url of items, such as Eshop, Fabrik, Hikashop, JGive ..
I don't want to judge on this issue yet, but: You should NEVER store the Itemid in the database/index of smart search, since then the Itemid is stored statically there. But if you change your menu structure, unpublish a menu item or create a "better" fitting menu item for a content item, all your old, stored URLs are broken. That is why you should not create a URL like index.php?option=com_content&view=article&id=42&catid=23&Itemid=12
and store that. The Itemid should always be decided on the fly by the router, not by the fixed input data. The Joomla core has been doing this since the rewrite of the router in 3.6 and I have been a strong advocate against the bullshit we have been doing before that in the core since Joomla 1.6.
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2024-04-27 14:11:55 |
Closed_By | ⇒ | rdeutz |
Dear Joomla team @joomla-cms-bot
Could you please fix this issue in the next version of the Joomla 4 and Joomla 5.
Thank you.