[3.2] Fix edge-case cache:clear fails #6747
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
DISCLAIMER: Team O.C.D. triggers within!
Problem
Under edge-case circumstances running
./app/nut cache:clear
would produce the following exception:Situation
The
app/cache/
_project _ directory will usually contain a.version
file, that let's Bolt quickly check (onboot()
) if the running version matches last boot … if not, it will perform some additional work … such as clearing the cache.Problem being that our implementation goes on to delete a bunch of other directories, one of which will contain Doctrine's cache directory.
Doctrine's cache only checks for the existence of, and creates if missing, its target directory on construct. This is sensible behaviour on the cache's part as its focus is pure speed!
Did two people on the core team have a huge cache refactor on their TODOs … Yes, yes we do!
Approach
Recreate Doctrine cache's base path as we nuke it after construction.
@CarsonF The chosen approach might slightly piss you off, and sorry but unless you have simple short term solutions, we're going to have to live with it. Our local adaptor (and Flysystem's for that matter) ignores the passed in
Config
object settings, so currently using it to recreate Doctrine's directory does it with restrictive permissions… and I am not personally comfortable loosening what is passed into the
Local
constructor, as while some people who can't ACL need0770
or even777
the cache directory contains sensitive data, and those of us that give the slightest 💩 about server/system/application security are not going to agree to it as a default with the current cache mount.