No Code Attached Yet
avatar hikashop-nicolas
hikashop-nicolas
18 Oct 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

avatar hikashop-nicolas hikashop-nicolas - open - 18 Oct 2023
avatar joomla-cms-bot joomla-cms-bot - change - 18 Oct 2023
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 18 Oct 2023
avatar hikashop-nicolas hikashop-nicolas - change - 18 Oct 2023
Title
[}
[4.4.0] Joomla\CMS\Mail\MailerFactory::createMailer(): Return value must be of type Joomla\CMS\Mail\MailerInterface, Joomla\CMS\Mail\Mail returned
avatar hikashop-nicolas hikashop-nicolas - edited - 18 Oct 2023
avatar hikashop-nicolas hikashop-nicolas - change - 18 Oct 2023
The description was changed
avatar hikashop-nicolas hikashop-nicolas - edited - 18 Oct 2023
avatar hikashop-nicolas
hikashop-nicolas - comment - 18 Oct 2023

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

avatar hikashop-nicolas hikashop-nicolas - change - 18 Oct 2023
The description was changed
avatar hikashop-nicolas hikashop-nicolas - edited - 18 Oct 2023
avatar Breiti85
Breiti85 - comment - 19 Oct 2023

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.

avatar brianteeman
brianteeman - comment - 19 Oct 2023

Which mailer are you using?

avatar Breiti85
Breiti85 - comment - 19 Oct 2023

PHP-Mail


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

avatar OctavianC
OctavianC - comment - 19 Oct 2023

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

avatar Breiti85
Breiti85 - comment - 19 Oct 2023

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.

avatar alikon alikon - close - 19 Oct 2023
avatar alikon
alikon - comment - 19 Oct 2023

closing as it is not from core

avatar alikon alikon - change - 19 Oct 2023
Status New Closed
Closed_Date 0000-00-00 00:00:00 2023-10-19 09:26:43
Closed_By alikon

Add a Comment

Login with GitHub to post a comment