Closed
Description
Symfony version(s) affected
6.3.5 (tested again in 6.3.7, problem persists)
Description
When upgrading from Symfony 5.4 to Symfony 6.3, my production environment experienced severe CPU load (x1000).
I traced it down to an issue regarding the secrets file being 'decoded' on every CLI command. I am following best practices of secrets:decrypt-to-local
so that the secrets are not required to be loaded on every request/command.
Troubleshooting futher, I narrowed down the problem to the inclusion of twig. Specifically, if I have a service that autowires twig (private Twig\Environment $twig
), this problem arises.
How to reproduce
composer create-project symfony/skeleton new_project/
composer install
composer require symfony/twig
./bin/console secrets:generate-keys
./bin/console secrets:set BLACK
- Create two commands, one of which extends twig, and the other which is configured to use the secret created in step 5 in the constructor
- Problem - command which extends twig needlessly runs script decrypt
To explicitly see the error at this point:
- Run
composer install
- Run
./bin/console secrets:decrypt-to-local
to create .env.dev.local, which should negate the need for secrets decryption - Run
./bin/console app:test
. Note lack of var_dump, even though a secret is being used in constructor. This is good! - Run
./bin/console app:test-twig
. var_dump! (No secrets even being used in constructor). This is bad!
Possible Solution
No response
Additional Context
No response