-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Preload broken with cache:warmup command #36793
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for the report, can you provide a small reproducing app please? |
Hi, I just tried to do that and failed miserably :) I created a new Thanks ! |
Back. Managed to reproduce it in https://github.com/ovrflo/symfony-preload-bug
Steps to reproduce: git clone https://github.com/ovrflo/symfony-preload-bug.git sfbug
cd sfbug
composer install
rm -rf var/cache/prod && APP_ENV=prod bin/console cache:warmup -v
cat var/cache/prod/App_KernelProdContainer.preload.php Is there anything else I can do to help ? I could help with a PR, but I don't know how to approach the bug. This feels like an issue with the design. Yeah, sure, I might be able to submit a PR with one or two extra checks to prevent this from happening, but that wouldn't be ok in the long run. Thanks ! |
Thanks, that makes understanding the issue very easy! Would you mind sending a PR to replace those require by require_once? |
Sure ! I'll have a PR soon :) Thanks ! |
…hen appending cache warmer-returned files to preload file.
Uh oh!
There was an error while loading. Please reload this page.
Symfony version(s) affected: 5.1.0-BETA1
Description
The generated preload file throws
PHP Fatal error: Cannot declare class Proxies\__CG__\App\Entity\SomeEntityName, because the name is already in use
. From what I can tell, the doctrine proxies are listed twice in the preload file. I tried debugging it and it looks like there are 2 pieces of code responsible for the bug:When running
cache:warmup
the kernel is building the container and calling the cache warmers and appending to the preload file. After the kernel built the container, the cache:warmer command is also calling the cache:warmers and append to the preload file. This is how doctrine proxies get appended twice.How to reproduce
It should be reproducible with symfony/demo
Possible Solution
I'd gladly submit a PR, but I have no idea how to fix this one.
Additional context
I also hit the issue reported in #35759. I had to setI'm running PHP 7.4.5.container.dumper.inline_class_loader=true
in order for my preload file to be generated.Edit
I worked around the issue by skipping
cache:warmup
and just calling bin/console (this way, the kernel does it's thing, but thecache:warmup
command won't append again).Also, I was apparently wrong about setting
container.dumper.inline_class_loader=true
. That will generateinclude
calls for hot path services and it will throw errors with preloading because all those files are already loaded. I have setcontainer.dumper.inline_class_loader=false
and it fixed the issue. I don't know exactly why it wasn't generating the preload file before setting it totrue
.The text was updated successfully, but these errors were encountered: