FriendsOfShopware / FroshTemplateMail

This plugin allows you to use Smarty in your template mails
MIT License
31 stars 5 forks source link

Cloned instance of template breaks subshop compatibility #13

Open mdjdev opened 2 years ago

mdjdev commented 2 years ago

PHP Version

7.4

Shopware Version

5.7.11

Actual behaviour

Hi,

I'm refering to this commit: https://github.com/FriendsOfShopware/FroshTemplateMail/commit/1dcc5594dc7c55d9aaa27a89c9a3f0de6db2995e

Cloning the instance breaks the subshop compatibility in our shop. The result is really strange. See example below.

Assume a system with a freshly cleared cache. I make an order in our German shop and get a correct order mail. I than make an order in our Dutch shop and I get an order mail with sender, subject and footer from the German shop. If I make an order in any other subshop, I still get an order mail with sender, subject and footer from the German shop.

It will stay like this until I clear the cache again. I found out that it is enough to clear the template cache. After clearing the template cache, I get mails with sender, subject and footer from the shop, that is cached first.

What is the advantage here to clone the object? Is this compulsory? If I revert commit 1dcc559, than the mails are fine and I can't find any downsides. But I would prefer to find the reason why the cloned object is dependent on the template cache.

Additional info: I can reproduce this behaviour only on our AWS EC2 instances but not on our physical dev servers. I have no clue why the clone function and the template cache behave differently on these systems. I am grateful for any advice.

Thank you for feedback in advance.

Expected behaviour

Mails are always sent in the right context

Steps to Reproduce?

larsbo commented 2 years ago

I observed that issue in 3 different shops with subshops, too. But I have no clue how that clone statement could produce such behavior. I thought about some kind of race condition as the reason for this bug 🤔

mdjdev commented 2 years ago

@larsbo I first thought it was due to the session management. I have no clue whats wrong with the clone statement either.

Could you please verify if removing the clone statement or clearing the template cache helps in your case, too?