Skip to content

[5.0] MailTemplate: Prevent notice in replaceTags#41679

Merged
HLeithner merged 6 commits intojoomla:5.0-devfrom
Hackwar:5.0-mailtemplates-notice
Oct 17, 2023
Merged

[5.0] MailTemplate: Prevent notice in replaceTags#41679
HLeithner merged 6 commits intojoomla:5.0-devfrom
Hackwar:5.0-mailtemplates-notice

Conversation

@Hackwar
Copy link
Member

@Hackwar Hackwar commented Sep 8, 2023

Summary of Changes

When registering a user, we export the whole data set of the user object to be used in the mail templates. Some of those values are actually NULL, for example isRoot or lastResetTime, etc. In line 350, we are doing a str_replace() on the tag with the value, in this case NULL. In PHP 8.1 (maybe even 8.0, didn't test.) this throws a notice, since str_replace() shouldn't be called with a NULL value.

I thought about how to solve the problem. The first idea was to just hopp over such an empty value, but that would leave a potential template tag in the mail. So I opted for replacing the value from NULL to an empty string.

Testing Instructions

Can we do this with a code review? It is difficult to provide testing instructions without fabricating a component to display the issue and not have it hidden in a redirect...

Actual result BEFORE applying this Pull Request

Expected result AFTER applying this Pull Request

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

@HLeithner
Copy link
Member

why is this a draft?

@HLeithner HLeithner added the bug label Sep 24, 2023
@Hackwar
Copy link
Member Author

Hackwar commented Sep 24, 2023

Because I didn't get around to write the test instructions yet.

@HLeithner HLeithner added the Maintainers Checked Used if the PR is conceptional useful label Oct 5, 2023
@HLeithner HLeithner added this to the Joomla! 5.0.1 milestone Oct 7, 2023
@Hackwar Hackwar marked this pull request as ready for review October 10, 2023 08:24
@Quy
Copy link
Contributor

Quy commented Oct 10, 2023

I have tested this item ✅ successfully on 3141e13

Before PR:
PHP Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in \libraries\src\Mail\MailTemplate.php on line 350


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

@alikon
Copy link
Contributor

alikon commented Oct 10, 2023

I have tested this item ✅ successfully on 3141e13


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

@joomla-cms-bot joomla-cms-bot removed this from the Joomla! 5.0.1 milestone Oct 10, 2023
@alikon
Copy link
Contributor

alikon commented Oct 10, 2023

RTC


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

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Oct 10, 2023
@HLeithner HLeithner added this to the Joomla! 5.0.1 milestone Oct 12, 2023
@HLeithner HLeithner merged commit 291b995 into joomla:5.0-dev Oct 17, 2023
@HLeithner
Copy link
Member

thanks

@joomla-cms-bot joomla-cms-bot removed RTC This Pull Request is Ready To Commit labels Oct 17, 2023
@Hackwar Hackwar deleted the 5.0-mailtemplates-notice branch March 22, 2024 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Maintainers Checked Used if the PR is conceptional useful

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants