Closed pumpe24 closed 1 year ago
Hi @pumpe24. Thank you for your report. To speed up processing of this issue, make sure that you provided the following information:
Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:
@magento give me 2.4-develop instance
- upcoming 2.4.x release
For more details, review the Magento Contributor Assistant documentation.
Add a comment to assign the issue: @magento I am working on this
To learn more about issue processing workflow, refer to the Code Contributions.
Join Magento Community Engineering Slack and ask your questions in #github channel.
:warning: According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.
:clock10: You can find the schedule on the Magento Community Calendar page.
:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.
:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel
This was introduced at https://github.com/magento/magento2/commit/46b9d30e5c4b5a0499148968b8c708a7acbbf3da, which unfortunately missed the Magento\Sales\Model\Order\Email\Sender\OrderSender
, so we can't just remove the call from getInfoBlockHtml
.
Hi @engcom-November. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:
[ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).Details
If the issue has a valid description, the label Issue: Format is valid
will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid
appears.
[ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description
label to the issue by yourself.
[ ] 3. Add Component: XXXXX
label(s) to the ticket, indicating the components it may be related to.
[ ] 4. Verify that the issue is reproducible on 2.4-develop
branchDetails
- Add the comment @magento give me 2.4-develop instance
to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.4-develop
branch, please, add the label Reproduced on 2.4.x
.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
[ ] 5. Add label Issue: Confirmed
once verification is complete.
[ ] 6. Make sure that automatic system confirms that report has been added to the backlog.
Verified the issue on Magento 2.4-develop branch and the issue is reproducible. [2022-06-16T13:23:41.336531+00:00] main.ERROR: Environment emulation nesting is not allowed. [] [] is triggered in system.log on sending invoice email. Hence confirming this issue.
@magento i am working on this
can confirm this issue on 2.4.4 - not only on invoices but also on credit memos
I am seeing this error in my system.log too since upgrading to Magento 2.4.4
main.ERROR: Environment emulation nesting is not allowed. [] []
What was the solution for this?
Same here, also seeing it after upgrade to 2.4.4. I also think it's affecting cart integrity/behavior, as in, I place the order, it completes successfully, I see the error in the log, the cart shows it's empty, I got to a category page and the same product and suddenly the cart shows 2 items. If I proceed with the order and try to place it, I get an exception:
[2022-08-10T23:09:54.909522+00:00] main.ERROR: Magento2 v3.2.7: The cart details have changed. Please refresh the page and try again (1). [] [] [2022-08-10T23:09:54.909680+00:00] main.ERROR: Magento2 v3.2.7: #0 /home/michael/www/Farmacias-Roma-Magento/htdocs/vendor/stripe/module-payments/Model/PaymentMethod.php(180): StripeIntegration\Payments\Model\PaymentElement->updateFromOrder()
(I didn't paste the whole stack trace, too big)
If I refresh the page, I can place the order successfully, but the same issue happens again.
We're having this issue with multiple shops as well.
any solution on this issue?
:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-6611 is successfully created for this GitHub issue.
:white_check_mark: Confirmed by @engcom-November. Thank you for verifying the issue.
Issue Available: @engcom-November, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.
Hello, having the same problem in magento 2.4.5.
Best regards, L Nunes
This is also occurring when sending out shipment notification emails in Magento 2.4.4-p1.
@nisha-vaghela are you working on this?
seeing this problem as well
Same here, possibly related to invoices being sent twice by cron (1 minute after each other)
The issue still exists in 2.4.5-p1 (community edition) when sending an email after shipping an order.
can confirm this for 2.4.5-p1
Same issue on 2.4.4-p2
Still exist on: Adobe Commerce ver. 2.4.5-p1
Internal team started working on the issue.
Hi @glo23503! :wave:
Thank you for collaboration. Only members of Community Contributors Team are allowed to be assigned to the issue. Please use @magento add to contributors team
command to join Contributors team.
Hi @o-iegorov. Thank you for working on this issue. Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:
Component: XXXXX
label(s) to the ticket, indicating the components it may be related to.2.4-develop
branch@magento give me 2.4-develop instance
to deploy test instance on Magento infrastructure. 2.4-develop
branch, please, add the label Reproduced on 2.4.x
.Hello, when will this PR be handled?
@glo23503: this issue got closed without any comments, any idea why?
Might have been fixed by ACP2E-1341: [On-Premise] Merchant Informed Core Issue Magento 2.4.4 main.ERROR: Environment emulation nesting is not allowed, unfortunately I can't seem to find a clean merge commit
Still present in 2.4.5-p1
@kassner @hostep @simonmaass anyone aware of a workaround? We're running into this as well.
@peterjaap hey peter! unfortunately not... currently living with the logspam... it doesnt seem to have an inpact on the actual functionality...
Same here. Any update on why this is closed? Is there a patch we can add to fix it temporarily?
I haven't tried this yet, but wouldn't adding $this->appEmulation->stopEnvironmentEmulation()
right before starting it kill the current emulation, thereby avoiding nesting?
Hello,
Can you please provide us a patch or any visibility on a PR?
@sivaschenko @sidolov @kassner , why this issue was closed? If it was fixed, please provide link to commit / pull request
Internal team already fixed the issue, merge commit id: https://github.com/magento/magento2/commit/3e5be99a940ef572e1a99fee8b9258fda5be9ff4
Thanks!
Relevant changes are here, here and here.
So the fix was moving the creation of the payment HTML block to outside the emulation which doesn't matter since that info is not store specific.
Here's the patch with just those changes:
@package magento/module-sales
@link https://github.com/magento/magento2/issues/35603
@link https://github.com/magento/magento2/commit/3e5be99a940ef572e1a99fee8b9258fda5be9ff4
@level 5
From f1538d3d453e9de884d78eb91c1177562d0e6a25 Mon Sep 17 00:00:00 2001
From: Sarmistha Martha <glo23503@adobe.com>
Date: Fri, 11 Nov 2022 13:11:19 +0530
Subject: [PATCH 12/51] ACP2E-1341: [On-Premise] Merchant Informed Core Issue
Magento 2.4.4 main.ERROR: Environment emulation nesting is not allowed
---
.../Order/Email/Sender/CreditmemoSender.php | 3 +-
.../Order/Email/Sender/InvoiceSender.php | 3 +-
.../Order/Email/Sender/ShipmentSender.php | 3 +-
diff --git a/app/code/Magento/Sales/Model/Order/Email/Sender/CreditmemoSender.php b/app/code/Magento/Sales/Model/Order/Email/Sender/CreditmemoSender.php
index 19dc627725138..22d5bc2b7a562 100644
--- a/app/code/Magento/Sales/Model/Order/Email/Sender/CreditmemoSender.php
+++ b/app/code/Magento/Sales/Model/Order/Email/Sender/CreditmemoSender.php
@@ -118,6 +118,7 @@ public function send(Creditmemo $creditmemo, $forceSyncMode = false)
if (!$this->globalConfig->getValue('sales_email/general/async_sending') || $forceSyncMode) {
$order = $creditmemo->getOrder();
+ $paymentHTML = $this->getPaymentHtml($order);
$this->appEmulation->startEnvironmentEmulation($order->getStoreId(), Area::AREA_FRONTEND, true);
$transport = [
'order' => $order,
@@ -126,7 +127,7 @@ public function send(Creditmemo $creditmemo, $forceSyncMode = false)
'creditmemo_id' => $creditmemo->getId(),
'comment' => $creditmemo->getCustomerNoteNotify() ? $creditmemo->getCustomerNote() : '',
'billing' => $order->getBillingAddress(),
- 'payment_html' => $this->getPaymentHtml($order),
+ 'payment_html' => $paymentHTML,
'store' => $order->getStore(),
'formattedShippingAddress' => $this->getFormattedShippingAddress($order),
'formattedBillingAddress' => $this->getFormattedBillingAddress($order),
diff --git a/app/code/Magento/Sales/Model/Order/Email/Sender/InvoiceSender.php b/app/code/Magento/Sales/Model/Order/Email/Sender/InvoiceSender.php
index 1ca2efef4d8f5..585da4d965840 100644
--- a/app/code/Magento/Sales/Model/Order/Email/Sender/InvoiceSender.php
+++ b/app/code/Magento/Sales/Model/Order/Email/Sender/InvoiceSender.php
@@ -126,6 +126,7 @@ public function send(Invoice $invoice, $forceSyncMode = false)
$order->setBaseTaxAmount((float) $invoice->getBaseTaxAmount());
$order->setBaseShippingAmount((float) $invoice->getBaseShippingAmount());
}
+ $paymentHTML = $this->getPaymentHtml($order);
$this->appEmulation->startEnvironmentEmulation($order->getStoreId(), Area::AREA_FRONTEND, true);
$transport = [
'order' => $order,
@@ -134,7 +135,7 @@ public function send(Invoice $invoice, $forceSyncMode = false)
'invoice_id' => $invoice->getId(),
'comment' => $invoice->getCustomerNoteNotify() ? $invoice->getCustomerNote() : '',
'billing' => $order->getBillingAddress(),
- 'payment_html' => $this->getPaymentHtml($order),
+ 'payment_html' => $paymentHTML,
'store' => $order->getStore(),
'formattedShippingAddress' => $this->getFormattedShippingAddress($order),
'formattedBillingAddress' => $this->getFormattedBillingAddress($order),
diff --git a/app/code/Magento/Sales/Model/Order/Email/Sender/ShipmentSender.php b/app/code/Magento/Sales/Model/Order/Email/Sender/ShipmentSender.php
index ba6d65a40c653..78aaf1a696e9a 100644
--- a/app/code/Magento/Sales/Model/Order/Email/Sender/ShipmentSender.php
+++ b/app/code/Magento/Sales/Model/Order/Email/Sender/ShipmentSender.php
@@ -120,6 +120,7 @@ public function send(Shipment $shipment, $forceSyncMode = false)
if (!$this->globalConfig->getValue('sales_email/general/async_sending') || $forceSyncMode) {
$order = $shipment->getOrder();
$this->identityContainer->setStore($order->getStore());
+ $paymentHTML = $this->getPaymentHtml($order);
$this->appEmulation->startEnvironmentEmulation($order->getStoreId(), Area::AREA_FRONTEND, true);
$transport = [
'order' => $order,
@@ -128,7 +129,7 @@ public function send(Shipment $shipment, $forceSyncMode = false)
'shipment_id' => $shipment->getId(),
'comment' => $shipment->getCustomerNoteNotify() ? $shipment->getCustomerNote() : '',
'billing' => $order->getBillingAddress(),
- 'payment_html' => $this->getPaymentHtml($order),
+ 'payment_html' => $paymentHTML,
'store' => $order->getStore(),
'formattedShippingAddress' => $this->getFormattedShippingAddress($order),
'formattedBillingAddress' => $this->getFormattedBillingAddress($order),
Thank you so much! Now it's absolutely clear that it was already fixed and not just closed by bot because of some glitch or whatever.
And the patch below worked for me and I was able to patch the files in my vendor directory. Note that I had to change the paths of the files and add an empty newline at the very end of the patch.
Just copy and paste the contents below into a file named emulation.patch
in your Magento base directory, then run git apply emulation.patch
in that directory.
diff --git a/vendor/magento/module-sales/Model/Order/Email/Sender/CreditmemoSender.php b/vendor/magento/module-sales/Model/Order/Email/Sender/CreditmemoSender.php
index 19dc627725138..22d5bc2b7a562 100644
--- a/vendor/magento/module-sales/Model/Order/Email/Sender/CreditmemoSender.php
+++ b/vendor/magento/module-sales/Model/Order/Email/Sender/CreditmemoSender.php
@@ -118,6 +118,7 @@ public function send(Creditmemo $creditmemo, $forceSyncMode = false)
if (!$this->globalConfig->getValue('sales_email/general/async_sending') || $forceSyncMode) {
$order = $creditmemo->getOrder();
+ $paymentHTML = $this->getPaymentHtml($order);
$this->appEmulation->startEnvironmentEmulation($order->getStoreId(), Area::AREA_FRONTEND, true);
$transport = [
'order' => $order,
@@ -126,7 +127,7 @@ public function send(Creditmemo $creditmemo, $forceSyncMode = false)
'creditmemo_id' => $creditmemo->getId(),
'comment' => $creditmemo->getCustomerNoteNotify() ? $creditmemo->getCustomerNote() : '',
'billing' => $order->getBillingAddress(),
- 'payment_html' => $this->getPaymentHtml($order),
+ 'payment_html' => $paymentHTML,
'store' => $order->getStore(),
'formattedShippingAddress' => $this->getFormattedShippingAddress($order),
'formattedBillingAddress' => $this->getFormattedBillingAddress($order),
diff --git a/vendor/magento/module-sales/Model/Order/Email/Sender/InvoiceSender.php b/vendor/magento/module-sales/Model/Order/Email/Sender/InvoiceSender.php
index 1ca2efef4d8f5..585da4d965840 100644
--- a/vendor/magento/module-sales/Model/Order/Email/Sender/InvoiceSender.php
+++ b/vendor/magento/module-sales/Model/Order/Email/Sender/InvoiceSender.php
@@ -126,6 +126,7 @@ public function send(Invoice $invoice, $forceSyncMode = false)
$order->setBaseTaxAmount((float) $invoice->getBaseTaxAmount());
$order->setBaseShippingAmount((float) $invoice->getBaseShippingAmount());
}
+ $paymentHTML = $this->getPaymentHtml($order);
$this->appEmulation->startEnvironmentEmulation($order->getStoreId(), Area::AREA_FRONTEND, true);
$transport = [
'order' => $order,
@@ -134,7 +135,7 @@ public function send(Invoice $invoice, $forceSyncMode = false)
'invoice_id' => $invoice->getId(),
'comment' => $invoice->getCustomerNoteNotify() ? $invoice->getCustomerNote() : '',
'billing' => $order->getBillingAddress(),
- 'payment_html' => $this->getPaymentHtml($order),
+ 'payment_html' => $paymentHTML,
'store' => $order->getStore(),
'formattedShippingAddress' => $this->getFormattedShippingAddress($order),
'formattedBillingAddress' => $this->getFormattedBillingAddress($order),
diff --git a/vendor/magento/module-sales/Model/Order/Email/Sender/ShipmentSender.php b/vendor/magento/module-sales/Model/Order/Email/Sender/ShipmentSender.php
index ba6d65a40c653..78aaf1a696e9a 100644
--- a/vendor/magento/module-sales/Model/Order/Email/Sender/ShipmentSender.php
+++ b/vendor/magento/module-sales/Model/Order/Email/Sender/ShipmentSender.php
@@ -120,6 +120,7 @@ public function send(Shipment $shipment, $forceSyncMode = false)
if (!$this->globalConfig->getValue('sales_email/general/async_sending') || $forceSyncMode) {
$order = $shipment->getOrder();
$this->identityContainer->setStore($order->getStore());
+ $paymentHTML = $this->getPaymentHtml($order);
$this->appEmulation->startEnvironmentEmulation($order->getStoreId(), Area::AREA_FRONTEND, true);
$transport = [
'order' => $order,
@@ -128,7 +129,7 @@ public function send(Shipment $shipment, $forceSyncMode = false)
'shipment_id' => $shipment->getId(),
'comment' => $shipment->getCustomerNoteNotify() ? $shipment->getCustomerNote() : '',
'billing' => $order->getBillingAddress(),
- 'payment_html' => $this->getPaymentHtml($order),
+ 'payment_html' => $paymentHTML,
'store' => $order->getStore(),
'formattedShippingAddress' => $this->getFormattedShippingAddress($order),
'formattedBillingAddress' => $this->getFormattedBillingAddress($order),
@mobweb I formatted the patch to use with vaimo/composer-patches, so you don't have to change the file paths in the patch. That's what @level 5
at the top of the patch does.
Applying the patch they way you describe doesn't help when you deploy Magento - that only changes the files locally.
So, when this is hitting a release or a quality patch? or is it already out there? (couldn't find it :( )
@qaniel: it's not included in Magento 2.4.6 which got released today, so you'll have to wait until version 2.4.7 which will be released in the year 2024 (I'm not joking). No idea if Adobe is going to turn this into a quality patch, maybe consider creating a request for it: https://github.com/magento/quality-patches/issues
But if you need it urgently, you'd probably want to follow @peterjaap's advise and use a custom patch.
@Yuwei9291
$order->getStoreId() ----> $order->createStoreId() it will solve the problem.
Where exactly did you add this?
@Yuwei9291
$order->getStoreId() ----> $order->createStoreId() it will solve the problem.
Where exactly did you add this?
Sorry that's my fault. this issue happened when I use an old email template. please ignore and sorry for the misunderstanding.
For my issues, the designer of the email template use objectManager to load product
$product = $objectManagerHere->get('Magento\Catalog\Model\Product')->load($productId);
and this row cause the Environment emulation nesting error. and once i checked and edited to $product = $objectManagerHere->create('Magento\Catalog\Model\Product')->load($productId); the problem solved.
I improved the code by using dependency injection by ChatGPT so I forget the detailed solution of the problem, just remember to change get to create.
Sorry I'm a seller not a programmer, the problem happened in multiple store mode when I using jopin's email template and once I removed it, the problem does not recur.
I hope my solution will tip off some users who have this error
On Magento Open Source 2.4.4,
$this->appEmulation->startEnvironmentEmulation($order->getStoreId(), Area::AREA_FRONTEND, true);
is added toMagento\Sales\Model\Order\Email\Sender\InvoiceSender::send
. While on this emulation there is a call toMagento\Payment\Helper\Data::getInfoBlockHtml
where the emulation is started again.This results in an error message
main.ERROR: Environment emulation nesting is not allowed
in system.log every time an invoice email is sent.Preconditions (*)
Steps to reproduce (*)
Expected result (*)
Actual result (*)
main.ERROR: Environment emulation nesting is not allowed