tweedegolf / swiftmailer-logger-bundle

Log emails sent with Swift Mailer in your Symfony2 project
MIT License
10 stars 7 forks source link

Using lifecycle events on entities with this bundle creates infinite loop #2

Open dsbaars opened 10 years ago

dsbaars commented 10 years ago

I'm using Event Subscribers in Doctrine to send an e-mail when an entity field is changed. The class is subscribed to the preUpdate event. The persisting of the e-mail log triggers another preUpdate, creating an infinite loop.

A possible solution could be the use of another entity manager for the e-mail logger, so events from the default $em are independent from the events triggered by the entitylogger.

(Environment: PHP 5.5.17, Symfony v2.3.20)

hugovandepol commented 10 years ago

Thanks for your remark, I'll look into it in the near future. Hope it didn't take you a long time to find out what was wrong.

On Thursday, October 9, 2014, Djuri Baars notifications@github.com wrote:

I'm using Event Subscribers in Doctrine to send an e-mail when an entity field is changed. The class is subscribed to the preUpdate event. The persisting of the e-mail log triggers another preUpdate, creating an infinite loop.

A possible solution could be the use of another entity manager for the e-mail logger, so events from the default $em are independent from the events triggered by the entitylogger.

(Environment: PHP 5.5.17, Symfony v2.3.20)

— Reply to this email directly or view it on GitHub https://github.com/tweedegolf/swiftmailer-logger-bundle/issues/2.