[Core][Optimalization] Assign fallback locale for command based requests#13545
Conversation
0b5af2b to
88c5a74
Compare
88c5a74 to
8883a6e
Compare
|
@SirDomin WDYT about an implementation similar to what I have described here: #9987 (comment) |
|
@vvasiloi it could work too, but im not sure about different contexts when using cli from behat/specs. This way make it generic in case when we add more ideas of this type. |
| { | ||
| $fallbackLocale = $this->translationLocaleProvider->getDefaultLocaleCode(); | ||
|
|
||
| if ($this->commandBasedChecker !== null && $this->commandBasedChecker->isRunningFromCommand()) { |
There was a problem hiding this comment.
Seeing this plus the extra constructor argument got me thinking, why not decorate this service instead of modifying it?
There was a problem hiding this comment.
I created 3rd not required argument along with deprecation note, i think both cases are good.
e1194c0 to
fd8ca81
Compare
lchrusciel
left a comment
There was a problem hiding this comment.
I can confirm, that this change makes significant improvement of CP process execution: https://blackfire.io/profiles/compare/39e14b49-45ec-4c52-91e9-9a8e7fbaedcd/graph
|
Thank you, @SirDomin! 🎉 |
…mand based requests (lchrusciel) This PR was merged into the 1.11 branch. Discussion ---------- | Q | A | --------------- | ----- | Branch? | 1.11 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Related tickets | | License | MIT I'm proposing alternative implementation to #13545, that takes into account request stack instead of env & SAPI. This way, we will have coherent behaviour among all envs which, in my opinion, will reduce possibility of bugs that exists on prod on dev, but where not detected by test. Perhaps, we should consider similar behaviour just as a locale context - so fallbacking in the locale context to config value if CLI is executed Commits ------- db2630e [Core][Optimization] Request stack based implementation of CLIContextChecker
After research we decided to assign fallback locale for messenger:consume command as it allows CatalogPromotions to be applied way faster than when checking locale for ~2000 product variants
There is also another way to check if we are running from command, with $_SERVER variable we can acccess:

but it gets abit tricky when using $_SERVER so decided to stay with this solution as the output can be the same