fix(store): set store/currency context for ActionInterface controllers (#40747)#40829
Open
lbajsarowicz wants to merge 2 commits into
Open
Conversation
Magento\Store\App\Action\Plugin\Context was registered as a plugin on Magento\Framework\App\Action\AbstractAction::dispatch(). Controllers that implement HttpGetActionInterface / ActionInterface directly without extending AbstractAction never triggered the plugin, so the store and currency values were never written to the HTTP context. For logged-in customers on full-page-cache hosts this manifested as the X-Magento-Vary cookie alternating between two hashes between requests, corrupting cache lookups for the affected endpoint. Mirror the migration already done for Customer/Tax/Weee context plugins: - plugin attaches to Magento\Framework\App\ActionInterface - beforeDispatch(AbstractAction, RequestInterface) becomes beforeExecute(ActionInterface), pulling the request from a constructor-injected RequestInterface (OM fallback preserves third-party constructor BC). Fixes magento#40747
|
Hi @lbajsarowicz. Thank you for your contribution!
Allowed build names are:
You can find more information about the builds here For more details, review the Code Contributions documentation. |
Contributor
Author
|
@magento run all tests |
Remove the _files/ContextTestSession.php helper and the require_once that loaded it. The abstract class existed only to expose getCurrencyCode on a SessionManagerInterface mock; replace with getMockBuilder()-> addMethods()->getMockForAbstractClass() directly in setUp so no external file is needed. This resolves the Magento2.PHP.NoRequireOnce PHPCS violation and eliminates the non-standard PSR-4 _files namespace path.
Contributor
Author
|
@magento run all tests |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Magento\Store\App\Action\Plugin\Contextwas registered as a plugin onMagento\Framework\App\Action\AbstractAction::dispatch(). Controllers thatimplement
HttpGetActionInterface/ActionInterfacedirectly (withoutextending
AbstractAction) never triggered the plugin, so the store andcurrency values were never written to the HTTP context.
For logged-in customers on full-page-cache hosts this manifested as the
X-Magento-Varycookie alternating between two hashes between requests,corrupting cache lookups for the affected endpoint.
Mirrors the migration already done for Customer/Tax/Weee context plugins:
Magento\Framework\App\ActionInterfacebeforeDispatch(AbstractAction, RequestInterface)becomesbeforeExecute(ActionInterface), pulling the request from aconstructor-injected
RequestInterface(OM fallback preservesthird-party constructor BC)
Fixes #40747
Fixed Issues
Store\App\Action\Plugin\Context::beforeDispatchnot migrated tobeforeExecute, causing X-Magento-Vary cookie corruption for ActionInterface controllersManual testing scenarios
HttpGetActionInterfacedirectly (noAbstractAction).X-Magento-Varycookie stable across requests (before: alternates between two hashes).Contribution checklist