Resolve store information lazily in config directive (#37815) - #41059
Open
lbajsarowicz wants to merge 1 commit into
Open
Resolve store information lazily in config directive (#37815)#41059lbajsarowicz wants to merge 1 commit into
lbajsarowicz wants to merge 1 commit into
Conversation
configDirective() resolved the store information object before checking
which config path was requested. Magento\Store\Model\Information loads a
region and a country entity from the database, so every {{config}} and
{{store}} directive in a CMS block or email template paid for two entity
loads that only the country_id and region_id paths actually use.
Resolve it inside those two branches only, and memoize it per store so a
template using both directives resolves it once.
Fixes magento#37815
|
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 |
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\Email\Model\Template\Filter::configDirective()resolved the store information object unconditionally, before checking which config path was actually requested:Magento\Store\Model\Information::getStoreInformationObject()loads two entities from the database:Only two config paths need that data —
general/store_information/country_idandgeneral/store_information/region_id. Every other{{config path="..."}}directive paid for a region load plus a country load and then discarded the result. BecauseMagento\Cms\Model\Template\Filterextends this class, a CMS page or block with N{{config}}/{{store}}directives performed 2×N redundant entity loads on every uncached render.This change:
Behaviour of the directive output is unchanged.
Fixed Issues (if relevant)
Fixes #37815
Manual testing scenarios (*)
Magento\Directory\Model\Region::loadandMagento\Directory\Model\Country::loadByCodeare called once per directive.After: neither is called at all for these paths.
Contribution checklist (*)