Ensure that both the layout and page layout have been cached before accessing #17756
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
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
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