Support

Akeeba Ticket System

#33057 Mail autoloader issue when posting a ticket

Posted in ‘Akeeba Ticket System for Joomla! 4 & 5’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Environment Information

Joomla! version
n/a
PHP version
n/a
Akeeba Ticket System version
n/a

Latest post by on Wednesday, 17 June 2020 17:17 CDT

carcam
System was throwing a: "Application stopped responding" on new tickets and when submitting a reply to a ticket I was the ajax call was getting a 500 error (same message actually).

Debugging the system lead me to an issue with the autoloader in which the problem seemed to be that the typed variables in PHP are expecting different classes from the $mailer object passed.

For instance in the file: /plugins/ats/mailfetch/mailfetch.php at line 128 the method onATSSendEmail expects the $mailer variable to be of type Joomla\CMS\Mail\Mail but the object passes is of type JMail (I know there is a prefix on the namespace use declaration, but that does not change the class type ;) )

I also have the same issue in the administrator/components/com_ats/Helper/Email.php file at line 219 in the inlineImages method.

I both cases just removing they type in the method declaration, made the system works, but obviously this looks wrong as at the end I'm not using the right class for the job (or the one the frawework expects).

I have Akeeba Tickets installed in another site (3.3.0) and I do not have this issue (and method declaration has not changed) in a very similar server setup so I think it might be related to any of the extensions I have installed on this site and I think actually it is related to the "override joomla emails" plugin by AcyMailing.

For sure when there is an override of the joomla classes, there is very few things you can do about it, but as this issue is very likely to happen through all Joomla 3 just wondering if you can think of a workaround so that we can have override email extensions and Akeeba Tickets working fine ;)

Also I thought it was a good idea to document this behaviour here so that other users can find it.

Any reply is appreciated.

Thanks!!

PS: Sorry if this post seems not very clear but I just came up with the override class idea when I was writing it (duck rubbing I guess).

nicholas
Akeeba Staff
Manager
JMail is a class alias to Joomla\CMS\Mail\Mail set during the application boot. Typehinting a method parameter works equally well no matter if you type hint against the FQN (fully qualified namespace) class or its alias. For a proof that this works on all versions of PHP supported by ATS please refer to this quick test on 3v4l.

Here's the thing. While Joomla registers a class alias it doesn't meant that a third party plugin can't register its own concrete class under this name! The problem is that now JMail is a concrete class which does not extend Joomla\CMS\Mail\Mail, therefore the type check fails. And here's the 3v4l proof of concept.

This is NOT a bug in Akeeba Ticket System. It's a bug in a third party plugin which is incompatible with Joomla 3.8 and later. If you really want to go down the completely misguided approach of completely overriding the system mailer (VERY BAD IDEA! COMPATIBILITY, FUNCTIONAL AND SECURITY BUGS AHEAD!) you need to override JMail in Joomla 3.7 or lower and Joomla\CMS\Mail\Mail on Joomla 3.8 and later since JMail was replaced by and became an alias to Joomla\CMS\Mail\Mail. By not doing that you have TWO system mailers, JMail and Joomla\CMS\Mail\Mail, which are incompatible with each other. Depending on whether the developer is using Factory::getMailer or Mail::getInstance() they'd end up with a different object. Therefore the plugin that caused this situation is incompatible with Joomla 3.8 or later. Oh, trust me, I made the mistake of buying one of them and it took me all of 18' before I deleted it and started writing my own.

Since this is a public ticket, let's break it down to the two most likely culprits and discuss the alternatives.

Plugins which convert plain text email to HTML. These are the most typical and worst offenders since they date back to the late Joomla 2.5 / early 3.1 days with minimal changes ever since. They override JMail causing the mailer class multiple personality issue described above. They also fail to incorporate security changes made to Joomla's mailer around 3.7.1 with regards to validating email addresses. If you want to see how it should really be done you can take a look at my MailMagic plugin. I use it on my personal blog site among other places. It needs a bit more polishing and some extra features before I can release it for free :)

Support for third party mailer services. Seriously, people, you do not need a third party plugin to have your site send emails with Amazon SES or any other third party email service. All of them support SMTP. Joomla supports SMTP too. Don't shoot your feet to avoid having to tie your shoelaces.

I hope that gives you more insight into what is going on. I can tell you that I'm not changing how ATS works because what I do is correct. What the third party extension does is wrong. That's what needs to be fixed instead of me breaking ATS :)

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

carcam
Hi Nicholas,
thank you very much for your detailed reply!!

I did not thought about the 2 classes problem as in my mind, ti was a class overrid (sigh!!).

I'm only using this plugin for a nice html email so I think your MailMagic option will be perfect for my project (and many other projects). So I'm just forking it and hopefully I will be able to contribute to it to ;)

Thanks again for your great support and extensions!!!

nicholas
Akeeba Staff
Manager
You're welcome!

To be fair, before you filed this ticket I didn't think it was possible to declare a concrete class with the same name as an already defined class alias. I had to test it with 3v4l before I could be sure that the crazy thing I thought was going on was actually happening.

Please do file a bug report with the third party developer of the problem extension. I believe that they probably don't know about this either. What PHP is doing is rather esoteric. From their perspective the extension didn't break in J3.8 and they didn't have to change it... but it is actually broken in a subtle and very important way.

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

System Task
system
This ticket has been automatically closed. All tickets which have been inactive for a long time are automatically closed. If you believe that this ticket was closed in error, please contact us.

Support Information

Working hours: We are open Monday to Friday, 9am to 7pm Cyprus timezone (EET / EEST). Support is provided by the same developers writing the software, all of which live in Europe. You can still file tickets outside of our working hours, but we cannot respond to them until we're back at the office.

Support policy: We would like to kindly inform you that when using our support you have already agreed to the Support Policy which is part of our Terms of Service. Thank you for your understanding and for helping us help you!