0

I have upgraded Magento version 2.3.5-p1 to Magento 2.4.0 after the upgrade it's showing me an error regarding newsletter files below are the error. I am running below command

php bin/magento setup:di:compile

Error Message

Compilation was started.
Interception cache generation... 6/8 [=====================>------]  75% 52 secs 572.0 MiBErrors during compilation:
        Magento\Newsletter\Model\Queue\TransportBuilder
                Extra parameters passed to parent construct: $messageFactory, $emailMessageInterfaceFactory, $mimeMessageInterfaceFactory, $mimePartInterfaceFactory, $addressConverter. File: /var/www/html/vendor/magento/module-newsletter/Model/Queue/TransportBuilder.php
Total Errors Count: 1

In Log.php line 92:
                            
  Error during compilation  
                        

Transport Builder code

public function __construct(
    FactoryInterface $templateFactory,
    MessageInterface $message,
    SenderResolverInterface $senderResolver,
    ObjectManagerInterface $objectManager,
    TransportInterfaceFactory $mailTransportFactory,
    MessageInterfaceFactory $messageFactory = null,
    EmailMessageInterfaceFactory $emailMessageInterfaceFactory = null,
    MimeMessageInterfaceFactory $mimeMessageInterfaceFactory = null,
    MimePartInterfaceFactory $mimePartInterfaceFactory = null,
    AddressConverter $addressConverter = null
) {
    parent::__construct(
        $templateFactory,
        $message,
        $senderResolver,
        $objectManager,
        $mailTransportFactory,
        $messageFactory,
        $emailMessageInterfaceFactory,
        $mimeMessageInterfaceFactory,
        $mimePartInterfaceFactory,
        $addressConverter
    );
    $this->emailMessageInterfaceFactory = $emailMessageInterfaceFactory ?: $this->objectManager
        ->get(EmailMessageInterfaceFactory::class);
    $this->mimeMessageInterfaceFactory = $mimeMessageInterfaceFactory ?: $this->objectManager
        ->get(MimeMessageInterfaceFactory::class);
    $this->mimePartInterfaceFactory = $mimePartInterfaceFactory ?: $this->objectManager
        ->get(MimePartInterfaceFactory::class);
    $this->addressConverter = $addressConverter ?: $this->objectManager
        ->get(AddressConverter::class);
}

It's extending below file Magento\Framework\Mail\Template\TransportBuilder

public function __construct(
    FactoryInterface $templateFactory,
    MessageInterface $message,
    SenderResolverInterface $senderResolver,
    ObjectManagerInterface $objectManager,
    TransportInterfaceFactory $mailTransportFactory,
    MessageInterfaceFactory $messageFactory = null,
    EmailMessageInterfaceFactory $emailMessageInterfaceFactory = null,
    MimeMessageInterfaceFactory $mimeMessageInterfaceFactory = null,
    MimePartInterfaceFactory $mimePartInterfaceFactory = null,
    AddressConverter $addressConverter = null
) {
    $this->templateFactory = $templateFactory;
    $this->objectManager = $objectManager;
    $this->_senderResolver = $senderResolver;
    $this->mailTransportFactory = $mailTransportFactory;
    $this->emailMessageInterfaceFactory = $emailMessageInterfaceFactory ?: $this->objectManager
        ->get(EmailMessageInterfaceFactory::class);
    $this->mimeMessageInterfaceFactory = $mimeMessageInterfaceFactory ?: $this->objectManager
        ->get(MimeMessageInterfaceFactory::class);
    $this->mimePartInterfaceFactory = $mimePartInterfaceFactory ?: $this->objectManager
        ->get(MimePartInterfaceFactory::class);
    $this->addressConverter = $addressConverter ?: $this->objectManager
        ->get(AddressConverter::class);
}

1 Answer 1

1

Try to update the Composer packages completely.

composer clear-cache
rm -rf vendor/* generated/* composer.lock
composer update -vvv
bin/magento setup:upgrade
bin/magento setup:di:compile
5
  • it's showing this error, Magento\Newsletter\Model\Queue\TransportBuilder::setFrom($from) should be compatible with Magento\Framework\Mail\Template\TransportBui lder::setFrom($from, $store = NULL) in /var/www/html/vendor/magento/module-newsletter/Model/Queue/TransportBuilder.php on line 191 Commented Aug 11, 2020 at 4:51
  • I passed this store in core file(temp basis) but after this same error which I reported in question is coming. Commented Aug 11, 2020 at 4:55
  • When I update newsletter Transport builder file with these params then it's working. parent::__construct( $templateFactory, $message, $senderResolver, $objectManager, $mailTransportFactory ); but why it's not coming in the default file. Commented Aug 11, 2020 at 8:00
  • It must be coming as you did by default. Commented Aug 11, 2020 at 16:18
  • Issue solved by adding required parameters in construct in core file Commented Aug 11, 2020 at 16:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.