Skip to content

Ensure that both the layout and page layout have been cached before accessing #17756

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

adammprost
Copy link

Description

The core code in lib/internal/Magento/Framework/View/Model/Layout/Merge.php -> load() assumes that if the layout has successfully retrieved from cache, that the page layout can also be successfully retrieved from cache. It's a fair assumption given that both caches are saved one after the other toward the end of the load() method, but it's an assumption nonetheless. This leaves the door open for race conditions, especially in a multi-web-node configuration with redis replication.

The code should be verifying that the page layout has actually been successfully retrieved from cache before using the value.

Manual testing scenarios

  1. Load a product listing page.
  2. In redis remove the page layout cached object for that page.
  3. Reload the product listing page.

Expected Result (prior to code change)

The page layout cache object for that page is regenerated and the page is rendered in its entirety.

Actual Result (prior to code change)

The page layout cache object for that page is not regenerated, the value set to $this->pageLayout in the code is 'false', and only the HTML body of the page is rendered (no html tags or head tags). The page is rendered broken.

Contribution checklist

  • [ x] Pull request has a meaningful description of its purpose
  • [ x] All commits are accompanied by meaningful commit messages
  • [ x] All new or changed code is covered with unit/integration tests (if applicable)
  • [ x] All automated tests passed successfully (all builds on Travis CI are green)

@magento-engcom-team
Copy link
Contributor

Hi @adammprost. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento-engcom-team give me test instance - deploy test instance based on PR changes
  • @magento-engcom-team give me {$VERSION} instance - deploy vanilla Magento instance

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

@ihor-sviziev
Copy link
Contributor

Hi @adammprost,
We already have such PR #16428
I'm closing this PR as duplicate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants