? ? Pending

User tests: Successful: Unsuccessful:

avatar bembelimen
bembelimen
20 Jun 2022

Pull Request for Issue # .

Summary of Changes

This PR prevents the execution of the relative to absolute URL conversation for Mail Templates when in CLI mode because this method uses (J)Uri which tries to load the URL from the server:

  1. https://github.com/joomla/joomla-cms/blob/4.2-dev/libraries/src/Mail/MailTemplate.php#L266
  2. https://github.com/joomla/joomla-cms/blob/4.2-dev/libraries/src/Mail/MailHelper.php#L209
  3. https://github.com/joomla/joomla-cms/blob/4.2-dev/libraries/src/Uri/Uri.php#L204
  4. https://github.com/joomla/joomla-cms/blob/4.2-dev/libraries/src/Uri/Uri.php#L142
  5. https://github.com/joomla/joomla-cms/blob/4.2-dev/libraries/src/Uri/Uri.php#L103

So sending mail templates in the cli does not work properly

Testing Instructions

Open libraries/src/Console/SiteDownCommand.php Line 97 and add:

$mailtemplate = new \Joomla\CMS\Mail\MailTemplate('com_contact.mail', 'en-GB');
$mailtemplate->addRecipient('test@example.com');
$mailtemplate->send();
exit;

open the terminal/cmd/powershell, navigate to your joomla folder and run:
php cli/joomla.php site:down

Actual result BEFORE applying this Pull Request

PHP Warning: Undefined array key "HTTP_HOST" in libraries/src/Uri/Uri.php on line 103

Expected result AFTER applying this Pull Request

No warning

avatar bembelimen bembelimen - open - 20 Jun 2022
avatar bembelimen bembelimen - change - 20 Jun 2022
Status New Pending
avatar bembelimen bembelimen - change - 20 Jun 2022
The description was changed
Title
Don't convert to absolute URLs in MailTemplate when in CLI
[4.2] Don't convert to absolute URLs in MailTemplate when in CLI
avatar bembelimen bembelimen - edited - 20 Jun 2022
avatar joomla-cms-bot joomla-cms-bot - change - 20 Jun 2022
Category Libraries
avatar wilsonge
wilsonge - comment - 20 Jun 2022

I think it's more complicated than this I'm afraid. Because if you have the live_site parameter set in global config then this would work. We also probably want it to work when in CLI too...

avatar bembelimen
bembelimen - comment - 20 Jun 2022

It still does not work, not because of the live site (this makes it nearly work) but because of the isSsl check line 143 (Uri.php) and getting the server instance above it outputs the warning...

avatar laoneo
laoneo - comment - 21 Jun 2022

I think you should elaborate a bit more why it fails, because I see it here the same as @wilsonge, that it should work with the live site. Just disabling it on cli is a hard measure. Pretty sure there are real world use cases where mail templates will be used on cli.

avatar wilsonge
wilsonge - comment - 21 Jun 2022

I understand what he's saying - the ssl detection also fails - because it still tries to parse the site to determine that. even if you used global config force ssl (which although it could be coded to work - not all sites even have ssl - and others will have had it setup with nginx/apache from the start without the joomla params - and we need to not hard fail on those sites).

avatar HLeithner
HLeithner - comment - 27 Jun 2022

This pull requests has been automatically converted to the PSR-12 coding standard.

avatar HLeithner HLeithner - change - 27 Jun 2022
Labels Added: ? ?
avatar HLeithner
HLeithner - comment - 2 May 2023

This pull request has been automatically rebased to 4.3-dev.

avatar obuisard obuisard - change - 15 Jul 2023
Title
[4.2] Don't convert to absolute URLs in MailTemplate when in CLI
[4.3] Don't convert to absolute URLs in MailTemplate when in CLI
avatar obuisard obuisard - edited - 15 Jul 2023
avatar HLeithner
HLeithner - comment - 30 Sep 2023

This pull request has been automatically rebased to 4.4-dev.

avatar tomsrocket
tomsrocket - comment - 24 Feb 2024

Testers beware: you can only test this issue if you have a (local) mail server! (which I don't)

avatar TLWebdesign TLWebdesign - test_item - 24 Feb 2024 - Tested unsuccessfully
avatar TLWebdesign
TLWebdesign - comment - 24 Feb 2024

I have tested this item 🔴 unsuccessfully on 0799bdd

I added the code to line 102 (has changes since instructions were written) of a J4.4.3 installation. Ran the site:down command and did not get an error. So can't replicate the issue.


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

avatar pe7er pe7er - test_item - 24 Feb 2024 - Tested unsuccessfully
avatar pe7er
pe7er - comment - 24 Feb 2024

I have tested this item 🔴 unsuccessfully on 0799bdd

I've tested this issue on Joomla! 4.4.3
There is no difference before and after the patch

After php cli/joomla.php site:down
the CLI states:

Site Offline

and I received an email (on local system using Mailhog) with non translated language strings:
Subject COM_CONTACT_ENQUIRY_SUBJECT
To "test@example.com" test@example.com
Plain text
COM_CONTACT_ENQUIRY_TEXT


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/38107.
avatar HLeithner HLeithner - change - 24 Apr 2024
Title
[4.3] Don't convert to absolute URLs in MailTemplate when in CLI
[4.4] Don't convert to absolute URLs in MailTemplate when in CLI
avatar HLeithner HLeithner - edited - 24 Apr 2024

Add a Comment

Login with GitHub to post a comment