Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.4.0] Joomla\CMS\Mail\MailerFactory::createMailer(): Return value must be of type Joomla\CMS\Mail\MailerInterface, Joomla\CMS\Mail\Mail returned #42164

Closed
hikashop-nicolas opened this issue Oct 18, 2023 · 7 comments

Comments

@hikashop-nicolas
Copy link
Contributor

hikashop-nicolas commented Oct 18, 2023

Steps to reproduce the issue

Not sure

Expected result

Mail instance is returned

Actual result

Error "Joomla\CMS\Mail\MailerFactory::createMailer(): Return value must be of type Joomla\CMS\Mail\MailerInterface, Joomla\CMS\Mail\Mail returned" happens

System information (as much as possible)

Joomla 4.4.0

Additional comments

This has been reported on several pages:
https://www.hikashop.com/forum/install-update/907149-problems-after-joomla-4-4-upgrade.html#355958
https://forum.joomla.org/viewtopic.php?f=812&p=3704289
https://joomla.stackexchange.com/questions/33416/error-when-upgrading-from-4-3-4-5o-4-4-error-meesage
https://forum.joomla.org/viewtopic.php?f=808&p=3704236

Example of callstack:

Function Location

1 () JROOT/libraries/src/Mail/MailerFactory.php:106
2 Joomla\CMS\Mail\MailerFactory->createMailer() JROOT/libraries/src/Factory.php:708
3 Joomla\CMS\Factory::createMailer() JROOT/libraries/src/Factory.php:490
4 Joomla\CMS\Factory::getMailer() JROOT/components/com_hikashop/controllers/product.php:257
5 productController->add_waitlist() JROOT/libraries/src/MVC/Controller/BaseController.php:693
6 Joomla\CMS\MVC\Controller\BaseController->execute() JROOT/administrator/components/com_hikashop/helpers/helper.php:2535
7 hikashopController->execute() JROOT/components/com_hikashop/hikashop.php:88
8 require_once() JROOT/libraries/src/Dispatcher/LegacyComponentDispatcher.php:71
9 Joomla\CMS\Dispatcher\LegacyComponentDispatcher::Joomla\CMS\Dispatcher{closure}() JROOT/libraries/src/Dispatcher/LegacyComponentDispatcher.php:73
10 Joomla\CMS\Dispatcher\LegacyComponentDispatcher->dispatch() JROOT/libraries/src/Component/ComponentHelper.php:361
11 Joomla\CMS\Component\ComponentHelper::renderComponent() JROOT/libraries/src/Application/SiteApplication.php:208
12 Joomla\CMS\Application\SiteApplication->dispatch() JROOT/libraries/src/Application/SiteApplication.php:249
13 Joomla\CMS\Application\SiteApplication->doExecute() JROOT/libraries/src/Application/CMSApplication.php:293
14 Joomla\CMS\Application\CMSApplication->execute() JROOT/includes/app.php:61
15 require_once() JROOT/index.php:32

@hikashop-nicolas hikashop-nicolas changed the title [} [4.4.0] Joomla\CMS\Mail\MailerFactory::createMailer(): Return value must be of type Joomla\CMS\Mail\MailerInterface, Joomla\CMS\Mail\Mail returned Oct 18, 2023
@hikashop-nicolas
Copy link
Contributor Author

I started to look into it, but I'm not sure what the problem is.
I can see that the createMailer function has been changed with Joomla 4.4.0 and that it is now deprecated and due to be removed in Joomla 6. But I don't see why that error would happen.
The callstack points, it seems to me, at some kind of incompatibility between the createMailer function of Factory in JROOT/libraries/src/Factory.php and the createMailer function of MailerFactory in JROOT/libraries/src/Mail/MailerFactory.php

@Breiti85
Copy link

Also 'Send Test Mail' fails:

#
#Date: 2023-10-19 06:43:38 UTC
#Software: Joomla! 4.4.0 Stable [ Pamoja ] 17-October-2023 16:00 GMT

#Fields: datetime priority clientip category message
2023-10-19T06:43:38+00:00 CRITICAL 2003:fe:4705:9d0b:a450:7dd4:404d:cf66 error Uncaught Throwable of type TypeError thrown with message "Joomla\CMS\Mail\MailerFactory::createMailer(): Return value must be of type Joomla\CMS\Mail\MailerInterface, Joomla\CMS\Mail\Mail returned". Stack trace: #0 [ROOT]/administrator/components/com_config/src/Model/ApplicationModel.php(1201): Joomla\CMS\Mail\MailerFactory->createMailer()
#1 [ROOT]/administrator/components/com_config/src/Controller/ApplicationController.php(270): Joomla\Component\Config\Administrator\Model\ApplicationModel->sendTestMail()
#2 [ROOT]/libraries/src/MVC/Controller/BaseController.php(693): Joomla\Component\Config\Administrator\Controller\ApplicationController->sendtestmail()
#3 [ROOT]/libraries/src/Dispatcher/ComponentDispatcher.php(143): Joomla\CMS\MVC\Controller\BaseController->execute()
#4 [ROOT]/libraries/src/Component/ComponentHelper.php(361): Joomla\CMS\Dispatcher\ComponentDispatcher->dispatch()
#5 [ROOT]/libraries/src/Application/AdministratorApplication.php(143): Joomla\CMS\Component\ComponentHelper::renderComponent()
#6 [ROOT]/libraries/src/Application/AdministratorApplication.php(186): Joomla\CMS\Application\AdministratorApplication->dispatch()
#7 [ROOT]/libraries/src/Application/CMSApplication.php(293): Joomla\CMS\Application\AdministratorApplication->doExecute()
#8 [ROOT]/administrator/includes/app.php(61): Joomla\CMS\Application\CMSApplication->execute()
#9 [ROOT]/administrator/index.php(32): require_once('/homepages/19/d...')
#10 {main}


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

@brianteeman
Copy link
Contributor

Which mailer are you using?

@Breiti85
Copy link

PHP-Mail


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

@OctavianC
Copy link
Contributor

I have a feeling this is caused by a 3rd party plugin overriding the Joomla! Mail class (had it happen before, but now with type hinting it could lead to this error)

  • Just to be sure, delete /administrator/cache/autoload_psr4.php in case there's some wrong mapping in there. It will get re-created on next page load.
  • If you have 3rd party plugins try to unpublish them all (System - Plugins - under Filter Options select 'system' from '- Select Type -') and see if this fixes the issue
  • Open /libraries/src/Mail/MailerFactory.php and look for the createMailer function: right after this line
$mailer = new Mail((bool) $configuration->get('throw_exceptions', true));

add these lines

$reflection = new \ReflectionClass($mailer);
var_dump($reflection->getName());
var_dump($reflection->getFilename());
die;

Take a look at the browser console - open the XHR request and show us the response.
image

@Breiti85
Copy link

Great, thank you!!!

I've disabled the plugin "AcyMailing - Override Joomla emails" and now everything works fine again!


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

@alikon
Copy link
Contributor

alikon commented Oct 19, 2023

closing as it is not from core

@alikon alikon closed this as completed Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants