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
Remove invalid hosts tracker settings cache #19021
Conversation
core/Config/Cache.php
Outdated
} | ||
} | ||
// remove invalid host dir | ||
rmdir($targetDir); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guess this actually does the same as Filesystem::unlinkRecursive()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sgiehl Thanks, I hadn't seen this one 🤦 Though, it doesn't do exactly what we want as it turns out. I wanted this method to be cautious and not delete anything unless it is an empty dir. It seems unlinkRecursive
would remove files inside the dirs too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we maybe avoid the path creation at all if we make the valid host check a static method and move the cache creation within that check?
@sgiehl AFAIK we can't because we first need to look into the config to see if it's a valid host before we can know it is a valid host. Although thinking about it now, when using Matomo in a multi tenancy environment where all the config files are in
|
@tsteur That looks to be a good solution. I'm not sure if we could put it on that line of code because We could add the same check just below:
|
I'm not too much into it but would think it pretty much does the same in the end 👍 |
I've stopped the cache from being created in two places in the IniChainSettings code now. The first one was ensuring that the cache being retrieved actually exists as a file. The second one is ensuring that the merged settings has a valid host setting present/set in the config. |
Appears I have a few tests that need fixing: |
I needed to update the test so that it didn't delete the original settings file when testing the cache. That step shouldn't be necessary to test that the cache is indeed being read; a new IniFileChain instance should suffice. However, this will have an affect, if an original INI settings file is deleted then it will not attempt to read the cache for it (due to The only other way to proceed would be the original cleanup method that originally was built. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had a look through the changes. For me this looks good now. Can't think of a reason why this may cause issues. Will merge it once the tests ran through
Description:
Ref: DEV-2583
When a tracking request supplies and invalid host an empty folder structure will be made in the cache directory if the GLOBAL
ENABLE_CONFIG_PHP_CACHE
istrue
. This change removes cleans up the directory once we can determine it is an invalid host.Notes
Ideally we wouldn't even create this structure to begin with, however, the vendor lib we use for the file cache throws an exception if a directory path isn't supplied. It was easier just to clean up in the case we have an invalid host after the fact. For the time being this will solve arbitrary dirs stacking up in the tmp folder.
Review