Delete config cache only after the cache file was written #14754
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.
I noticed we deleted the config cache in
IniFileChain
when wedumpChanges()
but the actual cache file is not yet overwritten. This actually happens in the config class. We need to make sure to delete the config cache only after we have written the config file. Otherwise there could be race conditions where the outdated config gets cached again, and if the user made two changes within one hour (that's how long the cache is active), then a previous change would be potentially undone.I was going to use the
Core.configFileChanged
event to listen to config file changes, however, at the time I would listen to the event usingPiwik::addAction('Core.configFileChanged', ...)
the DI container might not exist yet etc. Therefore I figured it's best to invalidate the cache specifically by calling the delete method within the config to ensure it'll work and not cause any trouble to something so critical.