Description
Symfony version(s) affected: 5.2.0
Description
A second invocation of bin/console cache:clear
removes directories from the cache directory that have been created by the first invocation. For certain vendors (such as JMS Serializer and Vich Uploader), this results in a full application breakdown, as they require the directory to exist.
This also means that a third invocation of the cache:clear
results in an exception for my application, as the JMS serializer checks for the directory existence during container startup.
The files I'm "missing" after the second invocation are:
annotation.php
App_KernelDevDebugContainer.xml
App_KernelDevDebugContainer.xml.meta
doctrine
jms_serializer
pools
serialization.php
translations
twig
validation.php
vich_uploader
webpack_encore.cache.php
How to reproduce
You should be able to investigate the behavior with a standard Symfony installation with Twig, as that is also one of the removed folders. However, it won't throw an error in that scenario, as Twig just recreates the required folders.
It looks like the second invocation doesn't execute the warmup stage, but running the cache:warmup
command doesn't help here due to the vendor missing the required folder.
Possible Solution
I'm not sure whether this is something that is broken within Symfony, or that the vendors should be making adjustments to be more robust for missing cache folders/missing warmup. However, IMO this is a massive difference between 5.1 and 5.2, so I believe that if this was intentional, it should be postponed to 6.0.