I'm writing a console command that creates articles on Joomla 4. It used to work on Joomla 3 with some hackery, but now I'm trying to write the native Joomla 4 implementation. However, the Content Component method boot
forces the load of the SiteApplication/WebApplication in the CLI context. This is the offending line that loads the Icon and the whole SiteApplication:
public function boot(ContainerInterface $container)
{
...
$this->getRegistry()->register('contenticon', new Icon($container->get(SiteApplication::class)));
...
}
ContentComponent running on the terminal.
ContentComponent is forcing the load of the WebApplication
PHP 7.4/Joomla 4.0.3
Labels |
Removed:
?
|
Labels |
Added:
No Code Attached Yet
|
As a workaround to save the day:
$_SERVER['HTTP_HOST'] = 'example.com';
$_SERVER['SCRIPT_NAME'] = '/not-running-as-a-command-line.html';
It looks like the Icon definition for the Web should be removed from the boot
method.
From my comment in #35722:
About #35625, the problem is that the php cli/joomla.php list
is firing the "System - Page Cache" when it's called from the console. Why would a console application fire the "System - Page Cache" plugin? It shouldn't. By default, a console application doesn't have to interact with the site cache.
The joomla console application calls to PluginHelper::importPlugin('system');
to initialize all system plugins. So, the problem seems to be that the "System - Page Cache" plugin tries to read the URI when it is executed in the console context. In my opinion, the plugin should do nothing and ignore the execution if it is the console context.
PS.... wrong issue.... I mean the other issue ...
@laoneo we need to think about this a bit more. Basically we need a way inside the Extension boot to skip loading things like the Html helpers if the primary application isn't a web application. Maybe we just need a marker for the active application in the container as a long term replacement for Factory::getApplication
Luckily in the short term the web application dependency isn't used as we removed the email method which was originally using it. So #36568 fixes this.
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2022-01-05 07:37:33 |
Closed_By | ⇒ | alikon |
The ContactComponent also has a similar Icon definition.
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/35818.