No Code Attached Yet
avatar anibalsanchez
anibalsanchez
14 Oct 2021

Steps to reproduce the issue

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)));
...
	}

Expected result

ContentComponent running on the terminal.

Actual result

ContentComponent is forcing the load of the WebApplication

System information (as much as possible)

PHP 7.4/Joomla 4.0.3

Additional comments

avatar anibalsanchez anibalsanchez - open - 14 Oct 2021
avatar anibalsanchez anibalsanchez - change - 14 Oct 2021
Labels Removed: ?
avatar joomla-cms-bot joomla-cms-bot - change - 14 Oct 2021
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 14 Oct 2021
avatar anibalsanchez
anibalsanchez - comment - 14 Oct 2021

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.

avatar anibalsanchez
anibalsanchez - comment - 14 Oct 2021

As a workaround to save the day:

        $_SERVER['HTTP_HOST'] = 'example.com';
        $_SERVER['SCRIPT_NAME'] = '/not-running-as-a-command-line.html';

This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/35818.
avatar anibalsanchez
anibalsanchez - comment - 15 Oct 2021

It looks like the Icon definition for the Web should be removed from the boot method.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/35818.

avatar alikon
alikon - comment - 17 Oct 2021

could you have a look at #35722 ?

avatar anibalsanchez
anibalsanchez - comment - 17 Oct 2021

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 ...

avatar wilsonge
wilsonge - comment - 5 Jan 2022

@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.

avatar alikon alikon - change - 5 Jan 2022
Status New Closed
Closed_Date 0000-00-00 00:00:00 2022-01-05 07:37:33
Closed_By alikon
avatar alikon alikon - close - 5 Jan 2022
avatar alikon
alikon - comment - 5 Jan 2022

please test #36568

Add a Comment

Login with GitHub to post a comment