Skip to content

Conversation

@Nyholm
Copy link
Member

@Nyholm Nyholm commented Oct 2, 2015

This commit introduced a BC break.

The suggested configuration from the Symfony docs look like this:

# app/config/config_prod.yml
monolog:
    handlers:
        mail:
            type:         fingers_crossed
            action_level: critical
            handler:      buffered
        buffered:
            type:    buffer
            handler: swift
        swift:
            type:       swift_mailer
            from_email: error@example.com
            to_email:   error@example.com
            subject:    An Error Occurred!
            level:      debug

The value of the handers['swift']['mailer'] will be default to 'mailer'. This is okey because the SwiftBundle has an alias for 'mailer'. ($container->setAlias('mailer', 'swiftmailer.mailer');).

When we use the 'mailer' in our AddSwiftMailerTransportPass we are looking for a service named `mailer.transport.real´ which does not exist and we will face an error like this:

Uncaught exception 'Exception' with message 'No transport available to flush mail queue' in xx/vendor/symfony/symfony/src/Symfony/Bridge/Monolog/Handler/SwiftMailerHandler.php:85Stack trace:
#0 xx/vendor/symfony/symfony/src/Symfony/Bridge/Monolog/Handler/SwiftMailerHandler.php(65): Symfony\Bridge\Monolog\Handler\SwiftMailerHandler->flushMemorySpool()
#1 xx/vendor/monolog/monolog/src/Monolog/Handler/MailHandler.php(36): Symfony\Bridge\Monolog\Handler\SwiftMailerHandler->send('[2015-10-02 11:...', Array)
#2 xx/vendor/monolog/monolog/src/Monolog/Handler/BufferHandler.php(90): Monolog\Handler\MailHandler->handleBatch(Array)
#3 xx/vendor/monolog/monolog/src/Monolog/Handler/BufferHandler.php(106): Monolog\Handler\BufferHandler->flush()#4 [internal function]: Monolog\Handler\BufferHandler->close()#5 {main} thrown

This PR make sure we don't break BC and fall back on the 'swiftmailer.transport.real' if no configured transport exists

@Nyholm
Copy link
Member Author

Nyholm commented Oct 2, 2015

Ping @tseho, I would like to have your opinion on this. Have I understood you commit correctly? What do you think about my change?

@tseho
Copy link
Contributor

tseho commented Oct 2, 2015

@Nyholm You are right, I thought I tested it correctly.

We DO need to fallback on "swiftmailer.transport" instead of "mailer.transport".

ping @Seldaek for approval.

@Seldaek
Copy link
Member

Seldaek commented Oct 2, 2015

Seems legit. Thanks

Seldaek added a commit that referenced this pull request Oct 2, 2015
Fixed BC break in AdDSwiftMailerTransportPass
@Seldaek Seldaek merged commit 7117b9a into symfony:master Oct 2, 2015
@Nyholm
Copy link
Member Author

Nyholm commented Oct 2, 2015

Thank you both for quick response!

@Nyholm Nyholm deleted the bcBreak branch October 2, 2015 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants