FroshTemplateMail icon indicating copy to clipboard operation
FroshTemplateMail copied to clipboard

Cloned instance of template breaks subshop compatibility

Open mdjdev opened this issue 2 years ago • 2 comments

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?

  • Update Shopware from 5.6.7 to 5.7.11
  • Update FroshTemplateMail from 1.0.0 to 1.1.2
  • Make orders in different subshops

mdjdev avatar Aug 16 '22 13:08 mdjdev

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 🤔

larsbo avatar Aug 16 '22 20:08 larsbo

@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?

mdjdev avatar Aug 17 '22 06:08 mdjdev