Skip to content

[4] Set HTTP_HOST from CLI#35722

Closed
alikon wants to merge 3 commits intojoomla:4.0-devfrom
alikon:patch-1
Closed

[4] Set HTTP_HOST from CLI#35722
alikon wants to merge 3 commits intojoomla:4.0-devfrom
alikon:patch-1

Conversation

@alikon
Copy link
Copy Markdown
Contributor

@alikon alikon commented Oct 2, 2021

Pull Request for Issue #35625 .

Summary of Changes

set a default

Testing Instructions

With the command php cli/joomla.php list, you get a list of all available CLI commands.
The script throws a PHP notice if the system plugin "System - Page Cache" is enabled:

before

Notice: Undefined index: HTTP_HOST in /xxx/libraries/src/Uri/Uri.php on line 103

after

No Notice

Documentation Changes Required

no

@PhilETaylor

This comment was marked as abuse.

@alikon
Copy link
Copy Markdown
Contributor Author

alikon commented Oct 2, 2021

make more sense now ?

@anibalsanchez
Copy link
Copy Markdown
Contributor

@alikon I don't think that it is a good idea to prepare Uri to understand the Application context and change the internal behavior according to the execution.

If an object has to use "isClient", then it is a bad signal and it is better to think twice about what we are doing.

The problem is the application context mismatch, why the current Application is calling Uri without sending the right parameter.

As I pointed out in #35818, the problem is that the Content Component boots the Site Application with $container->get(SiteApplication::class). The Content Component doesn't have to force the Site Application.

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.

@ceford
Copy link
Copy Markdown
Contributor

ceford commented Oct 21, 2021

I have tested this item ✅ successfully on a510896

With the code and tutorial I wrote yesterday I can confirm this works as described.


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

@anibalsanchez
Copy link
Copy Markdown
Contributor

I have tested this item 🔴 unsuccessfully on a510896

No No No.

Faking an URL 'localhost' into $_SERVER['HTTP_HOST'] is not the way to solve it.

The problem is the "System - Page Cache" plugin executing in the console context. The plugin must ignore the execution when it is in the console context.


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

@alikon
Copy link
Copy Markdown
Contributor Author

alikon commented Nov 6, 2021

closed as per #35877 merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants