Load symfony container in front - #32719
Conversation
|
FYI, @FabienPapet opened (and closed) this PR #29997 |
b2d8220 to
bcf3bcd
Compare
bcf3bcd to
2611455
Compare
148aba0 to
b58a3ea
Compare
62a492b to
fb55a48
Compare
fb55a48 to
3ea9881
Compare
| public function __construct(string $environment, bool $debug) | ||
| { | ||
| parent::__construct($environment, $debug); | ||
| } |
| $container->addCompilerPass(new LoadServicesFromModulesPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, self::LOAD_MODULE_SERVICES_PASS_PRIORITY); | ||
| $container->addCompilerPass(new LoadServicesFromModulesPass($this->appType), PassConfig::TYPE_BEFORE_OPTIMIZATION, self::LOAD_MODULE_SERVICES_PASS_PRIORITY); |
There was a problem hiding this comment.
This is super dangerous. The DI should never know if we are in a frontend or a backend context. This information should come from the request for example, but should not be used inside a compiler pass.
There was a problem hiding this comment.
We should remove this file since we already have .env
| public function __construct(string $environment, bool $debug) | ||
| { | ||
| parent::__construct($environment, $debug); | ||
| $this->appType = AppKernel::TYPE_ADMIN; |
There was a problem hiding this comment.
I think appType it's not handy. We should remove it and based the comparison on $kernel::class (which should be either AdminKernel or FrontKernel)
|
Hi @Hlavtox, yes and it's a big slow. To know what is going on, I want to reinstall a fresh PrestaShop instance and retests some pages like I did. |
tleon
left a comment
There was a problem hiding this comment.
LGTM, tho I don't think I know the topic enought to aprouve this on my own. Would love to have other inputs
6a9d8b7 to
311bc21
Compare
| services: | ||
| _defaults: | ||
| public: true | ||
|
|
||
| prestashop.core.filter.front_end_object.main: | ||
| class: PrestaShop\PrestaShop\Core\Filter\FrontEndObject\MainFilter | ||
| autoconfigure: true | ||
| arguments: | ||
| - cart: '@prestashop.core.filter.front_end_object.cart' | ||
| customer: '@prestashop.core.filter.front_end_object.customer' | ||
| shop: '@prestashop.core.filter.front_end_object.shop' | ||
| configuration: '@prestashop.core.filter.front_end_object.configuration' | ||
|
|
||
| prestashop.core.filter.front_end_object.product: | ||
| class: PrestaShop\PrestaShop\Core\Filter\FrontEndObject\ProductFilter | ||
|
|
||
| prestashop.core.filter.front_end_object.cart: | ||
| class: PrestaShop\PrestaShop\Core\Filter\FrontEndObject\CartFilter | ||
| arguments: | ||
| - '@prestashop.core.filter.front_end_object.product_collection' | ||
|
|
||
| prestashop.core.filter.front_end_object.search_result_product: | ||
| class: PrestaShop\PrestaShop\Core\Filter\FrontEndObject\SearchResultProductFilter | ||
|
|
||
| prestashop.core.filter.front_end_object.customer: | ||
| class: PrestaShop\PrestaShop\Core\Filter\FrontEndObject\CustomerFilter | ||
|
|
||
| prestashop.core.filter.front_end_object.shop: | ||
| class: PrestaShop\PrestaShop\Core\Filter\FrontEndObject\ShopFilter | ||
|
|
||
| prestashop.core.filter.front_end_object.configuration: | ||
| class: PrestaShop\PrestaShop\Core\Filter\FrontEndObject\ConfigurationFilter | ||
|
|
||
| prestashop.core.filter.front_end_object.product_collection: | ||
| class: PrestaShop\PrestaShop\Core\Filter\CollectionFilter | ||
| calls: | ||
| - method: queue | ||
| arguments: | ||
| - [ '@prestashop.core.filter.front_end_object.product' ] | ||
|
|
||
| prestashop.core.filter.front_end_object.search_result_product_collection: | ||
| class: PrestaShop\PrestaShop\Core\Filter\CollectionFilter | ||
| calls: | ||
| - method: queue | ||
| arguments: | ||
| - [ '@prestashop.core.filter.front_end_object.search_result_product' ] | ||
|
|
||
| prestashop.adapter.module.repository.module_repository: | ||
| class: 'PrestaShop\PrestaShop\Adapter\Module\Repository\ModuleRepository' | ||
| arguments: | ||
| - !php/const _PS_ROOT_DIR_ | ||
| - !php/const _PS_MODULE_DIR_ | ||
|
|
||
| prestashop.translation.translator_language_loader: | ||
| class: PrestaShopBundle\Translation\TranslatorLanguageLoader | ||
| arguments: | ||
| - '@prestashop.adapter.module.repository.module_repository' |
There was a problem hiding this comment.
Regarding this ADR, can you use FQCN for services names https://github.com/PrestaShop/ADR/blob/master/0019-FQCN-Autowiring.md ?
There was a problem hiding this comment.
This is a configuration for legacy services used in front, and I can't really switch to FQCN without some big changes that can introduce some big breaking changes (and if we delete theses alias).
But, I think that can be done in another PR and why not optimize this system too.
What do you think about it?
5cdb1e7 to
1369ab7
Compare
matks
left a comment
There was a problem hiding this comment.
Implementation is OK for me 👍
There's a little comment from @mflasquin I have nothing to add
|
@matks It cannot be merged if it slows down cart loading 3 times in production mode |
|
@Hlavtox, after some new benchmarks with this system, I don't be able to reproduce the loading X3 in production mode. So I think that can be ok to merge seen that this implementation is behind a feature flag. |
M0rgan01
left a comment
There was a problem hiding this comment.
Thank you for the performance comparison table :) The changes announce a good thing
aniszr
left a comment
There was a problem hiding this comment.
Hello @boherm
I tested your PR and it LGTM!
The modifications done on the.env file didn't cause any problems on the FO:heavy_check_mark:
- Auto Test (without container activated): https://github.com/aniszr/ga.tests.ui.pr/actions/runs/6010082838
- Auto Test (container activated): https://github.com/boherm/ga.tests.ui.pr/actions/runs/6010749136
QA ✔️
Thanks!
|
QA approved, well done! Message to the maintainers: do not forget to milestone it before the merge. |
|
Big thanks to @boherm for this PR ! |
|
@mflasquin Don't forget the milestone |
|
This was already a feature (see https://github.com/PrestaShop/PrestaShop/blob/develop/classes/container/LegacyCompilerPass.php), you have to tag a service with the tag "front" to make it available in every legacy controller. What's the difference with this new container ? An old exemple of integration => https://github.com/friends-of-presta/masterclass/blob/master/config/services.yml#L53 |
|
Hummm good point @mickaelandrieu ! |



We can enable this experimental feature with new dotenv file!
PS_CONTAINER_V2_FRONT=truein.envfile.Notes: You can run tests ui with this PR: PrestaShop/ga.tests.ui.pr#34.
Tests:
Some performances tests:
(with PHP 8.1, no opcache, no docker, with apache & mysql 8.0.33 on MacBook Pro M2 16go Ram)
when connected with one product
when connected with 19 products
when connected with 40 products
Conclusions about performances tests: