Fix unnecessary loading of directory data for config directives#40602
Open
mcjwsk wants to merge 1 commit intomagento:2.4-developfrom
Open
Fix unnecessary loading of directory data for config directives#40602mcjwsk wants to merge 1 commit intomagento:2.4-developfrom
mcjwsk wants to merge 1 commit intomagento:2.4-developfrom
Conversation
|
Hi @mcjwsk. 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
This pull request optimizes the
configDirective()method inMagento\Email\Model\Template\Filterby eliminating redundant calls to retrieve the store information object.Previously,
getStoreInformationObject()was executed every time the directive was processed, even within the same request scope. This resulted in unnecessary repeated instantiation and data fetching.The change introduces a private cache (
$storeInformationObject) along with a dedicated accessor methodgetStoreInformationObject($storeId)that lazily loads and reuses the object.Additionally:
$storeand$storeInformationObjinitialization when not required.This improves performance and reduces overhead when processing email templates with multiple
configdirectives.Related Pull Requests
N/A
Fixed Issues
N/A
Manual testing scenarios
Configure store information in admin panel:
Create or modify an email template containing:
Trigger an email that uses this template (e.g. order confirmation).
Verify that:
(Optional) Add logging or use profiler to confirm:
getStoreInformationObject()is executed only once per filter instance.Questions or comments
This change assumes that
storeInformationObjectcan be safely reused within a singleFilterinstance lifecycle. Please confirm that there are no edge cases where multiple store contexts could be processed within the same instance.Contribution checklist