magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.55k stars 9.32k forks source link

M2.2.7 : FPC clears checkout session on uncached pages and Magento_Persistent module disabled #21614

Open kanduvisla opened 5 years ago

kanduvisla commented 5 years ago

I have this strange issue that when I enabled Full Page Cache (FPC), my checkout session's quote_id is removed whenever the visitor comes on an uncached page.

I suspect that this issue has something to do with the \Magento\Checkout\Model\Layout\DepersonalizePlugin, which runs a clearStorage() on the session object so that no session-related information will be rendered accidentally in the templates.

However, as soon as the session is closed, the "cleared" session data is written to the session. So the next time the page loads, there is no quote ID and a new quote is generated for the customer.

I'm not sure what goes wrong or what might be causing this, but it's already bugging me for 2 days now. I understand the need of clearing the session data for template rendering, but I was always in the assumption that this was temporary and not actually changing the session itself.

Preconditions (*)

  1. Magento 2.2.7

Steps to reproduce (*)

  1. Enable all caches
  2. Disable the Magento_Persistent module (bin/magento module:disable)
  3. Add a product to the cart
  4. Change the URL with ?foo=bar for example, so a new page will be called (cache miss)
  5. Check the cart.

Expected result (*)

  1. Product should still be in the cart

Actual result (*)

  1. Cart is empty (because my session no longer has a known quote_id)
magento-engcom-team commented 5 years ago

Hi @kanduvisla. Thank you for your report. To help us process this issue please make sure that you provided the following information:

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento-engcom-team give me 2.3-develop instance - upcoming 2.3.x release

For more details, please, review the Magento Contributor Assistant documentation.

@kanduvisla do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?

magento-engcom-team commented 5 years ago

Hi @engcom-backlog-nazar. 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:

ghost commented 5 years ago

Hi @kanduvisla thank you for your report. is there any additional steps to reproduce this issue ?

kanduvisla commented 5 years ago

@engcom-backlog-nazar I'm trying to figure out what goes wrong. I have multiple Magento 2 installations, but this only affects one. That makes it so strange.

I am currently researching the session handlers. The weird part is (on a vanilla installation) that when writeClose() is called, the checkout session is empty, but as soon as (on a new request) the session_start() is called, the checkout session is repopulated. But this seems to be the part that is not working in my other setup.

kanduvisla commented 5 years ago

At first tests it seems that disabling the persistent cart module caused this issue. I'll check if re-enabling it solves it.

kanduvisla commented 5 years ago

I re-enabled the module and it seems that that solves the issue. So that makes this issue reproducible (already tested it on a vanilla installation):

I'll update this issue.

@engcom-backlog-nazar : is this a bug or a feature? It looks like that if you disable the Magento_Persistent-module the FPC will flush your checkout session as soon as it misses a cache.

magento-engcom-team commented 5 years ago

:white_check_mark: Confirmed by @engcom-backlog-nazar Thank you for verifying the issue. Based on the provided information internal tickets MAGETWO-98649, MAGETWO-98650 were created

Issue Available: @engcom-backlog-nazar, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

navidnadali commented 5 years ago

Hi @magento - Is there an update on this one? We are having this issue on a number of sites

prabhash76 commented 5 years ago

So @magento-engcom-team when we are supposed to get the re-solved version of magento.

navidnadali commented 5 years ago

@magento-engcom-team please can you provide an update, we have multiple clients with this issue

prabhash76 commented 5 years ago

@magento-engcom-team I Have a problem when FPC is enable on my M2 2.3. The problem is when I add a product to the cart and then goes to another category. then the cart willl be empty. When FPC is disable all works fine.

tprocter1984 commented 5 years ago

Hi @magento-engcom-team any news on this issue?

hostep commented 5 years ago

Also running against this problem with Magento 2.3.1 and 2.3.2, enabling the Persistent module again fixes it over here.

Also, this is probably a duplicate of https://github.com/magento/magento2/issues/17973 although this issue here has much better information.

erikhansen commented 4 years ago

@magento-engcom-team The 2.3.3 release notes say that:

Full-page cache no longer clears out the checkout session data on uncached pages when the Magento_Persistent module is disabled. GitHub-21614

If this indeed the case, can you provide a link to the commit that fixed this issue and then close this issue and issue #17973?

erikhansen commented 4 years ago

@magento-engcom-team I'm running on Magento Open Source 2.3.3-p1 and I'm still able to reproduce this issue. Can you post a link to the commit where this was purportedly fixed?

Sherbieny commented 4 years ago

@magento-engcom-team I am running on Magento Enterprise 2.3.2(with Magento_Persistent enabled) and I am able to reproduce the issue. When quickly adding consecutive items to cart via AJAX quote is dropped after first addition, new one created and assigned, then the old one is added back again with the third or fourth addition, and sometimes it just keeps jumping from one to another

github-jira-sync-bot commented 3 years ago

:white_check_mark: Jira issue https://jira.corp.magento.com/browse/AC-1034 is successfully created for this GitHub issue.

m2-assistant[bot] commented 3 years ago

:white_check_mark: Confirmed by @engcom-Hotel. Thank you for verifying the issue.
Issue Available: @engcom-Hotel, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

adammberk commented 1 year ago

What is the resolution for this issue? ✅ Jira issue https://jira.corp.magento.com/browse/AC-1034 is successfully created for this GitHub issue. Without jira access how can one determine the status of the issue? I am having the same problem in 2.4.3 and 2.4.5p1 where the session is cleared when the PlaceOrder controller executes. This causes a failure in checkout after a successful cybersource payment authorization. Thanks for your attention.

engcom-Hotel commented 1 year ago

Hello @adammberk,

We will update you here on this issue when the fix will be fixed and merged with the development branch.

Thanks

adammberk commented 1 year ago

@engcom-Hotel I wanted to add to my comment that I have put debugging statements into the Depersonalize class. What I am observing is that the session is being cleared in PlaceOrder and Success controllers whether or not the Magento_Persistent module is enabled or disabled and whether of not the depersonalize flag is set to true or false as shown in this debug statement:
report.DEBUG: Magento\PageCache\Model\DepersonalizeChecker::checkIfDepersonalize {"request":"checkout:success","depersonalize ":false,"has quote in session":false}