User tests: Successful: Unsuccessful:
When extending the MailTemplate class with my own implementation to override the getTemplate(...) method. The send(...) method is still using the original method.
Create the file libraries/src/Mail/MailTemplateExtended.php with the following code:
<?php
namespace Joomla\CMS\Mail;
\defined('_JEXEC') or die;
class MailTemplateExtended extends MailTemplate
{
public static function getTemplate($key, $language)
{
exit('hello world');
}
}
$mailtemplate = new MailTemplateExtended('com_messages.new_message', 'en-GB');
$mailtemplate->addRecipient('test@example.com');
$mailtemplate->send();
The old getTemplate is called.
The script stops with "hello world", which means, the new method is called.
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
| Status | New | ⇒ | Pending |
| Category | ⇒ | Libraries |
I have tested this item ✅ successfully on 58b5996
| Status | Pending | ⇒ | Ready to Commit |
RTC
| Title |
|
||||||
| Labels |
Added:
RTC
bug
PR-5.4-dev
|
||
Was discussed in maintainer meeting, as it is no final class it should be possible to override and therefore it is a bug.
✅ Final test before merge with JBT
cp cli/joomla.php cli/test.php, inserted use Joomla\CMS\Mail\MailTemplateExtended; in the beginning and replaced last line $app->execute(); with the three given linesgh pr checkout 46448 and the scripts stops with hello world| Status | Ready to Commit | ⇒ | Fixed in Code Base |
| Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2025-11-26 12:57:05 |
| Closed_By | ⇒ | muhme |
Thank you @bembelimen for your conttribution. Thank you @TLWebdesign and @alikon for testing.
I have tested this item ✅ successfully on 58b5996
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46448.