joomla / joomla-cms

Home of the Joomla! Content Management System
https://www.joomla.org
GNU General Public License v2.0
4.73k stars 3.64k forks source link

[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 closed 11 months ago

hikashop-nicolas commented 11 months ago

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 commented 11 months ago

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 commented 11 months ago

Also 'Send Test Mail' fails:

#

<?php die('Forbidden.'); ?>

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 commented 11 months ago

Which mailer are you using?

Breiti85 commented 11 months ago

PHP-Mail


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

OctavianC commented 11 months ago

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)

Breiti85 commented 11 months ago

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 commented 11 months ago

closing as it is not from core