-
Notifications
You must be signed in to change notification settings - Fork 226
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
Added logic to clean root files #5761
Conversation
@CrochetFeve0251 We are only clearing files, i.e. not folders that exist in the root folder. If:
Visiting those URLs will serve cached content given that cache for them exists. So, even when using When clearing language-specific cache, e.g. that of English, we should clear every file and folder in the root directory except for the folders of other languages, e.g. The same should happen when we clear a post's cache. In this case, we shouldn't delete the whole @piotrbak What do you think? |
@vmanthos If we're leaving only folders, not cached files, I believe this is acceptable side effect. It doesn't bring any defects in functionality at all. What do you think? |
@piotrbak With the following steps we'll get stale cached content:
Preconditions: Apache server and our rewrite rules in place. The result of the offered steps will be the norm for anyone using WP Rocket and then switching on WPML's "Use directory for default language" option. @CrochetFeve0251 suggested clearing the cache when WPML's option is enabled/disabled which is a good solution. The question at hand is if that should be done for the whole cache, clearing even the cache of URLs whose permalinks haven't changed, or trying to clear the cache just for the affected URLs. |
I think we can clear the whole cache. That kind of change is not a frequent one |
@CrochetFeve0251 Thank you for the PR. Please find my notes below:
PHP Fatal error: Uncaught TypeError: array_keys(): Argument #1 ($array) must be of type array, bool given in /shared/httpd/wprocketest/htdocs/wp-content/plugins/wp-rocket/inc/ThirdParty/Plugins/I18n/WPML.php:135
Stack trace:
#0 /shared/httpd/wprocketest/htdocs/wp-content/plugins/wp-rocket/inc/ThirdParty/Plugins/I18n/WPML.php(135): array_keys(false)
#1 /shared/httpd/wprocketest/htdocs/wp-includes/class-wp-hook.php(310): WP_Rocket\ThirdParty\Plugins\I18n\WPML->remove_root_cached_files('/shared/httpd/w...')
#2 /shared/httpd/wprocketest/htdocs/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters(NULL, Array)
#3 /shared/httpd/wprocketest/htdocs/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#4 /shared/httpd/wprocketest/htdocs/wp-content/plugins/wp-rocket/inc/functions/files.php(806): do_action('after_rocket_cl...', '/shared/httpd/w...', '', 'https://wprocke...')
#5 /shared/httpd/wprocketest/htdocs/wp-content/plugins/wp-rocket/inc/common/purge.php(438): rocket_clean_domain('')
#6 /shared/httpd/wprocketest/htdocs/wp-includes/class-wp-hook.php(308): do_admin_post_rocket_purge_cache('')
#7 /shared/httpd/wprocketest/htdocs/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters('', Array)
#8 /shared/httpd/wprocketest/htdocs/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#9 /shared/httpd/wprocketest/htdocs/wp-admin/admin-post.php(85): do_action('admin_post_purg...')
#10 {main}
thrown in /shared/httpd/wprocketest/htdocs/wp-content/plugins/wp-rocket/inc/ThirdParty/Plugins/I18n/WPML.php on line 135
Issues 2 & 3 happen when the following snippet is used: add_action( 'after_rocket_clean_domain', function(){
error_log( " run\n", 3, ABSPATH . 'RCD.log');
}); Can you please look into these? 🙏 |
…ry' into bug/5611-wpml-clean-root-directory
@CrochetFeve0251 All the issues I mentioned in the previous comment are resolved. Thank you! @piotrbak I noticed that URLs following the previous permalinks scheme are still present in the Visiting such a URL, e.g. On top of clearing the cache when enabling/disabling the WPML feature, I believe we should remove the existing URLs from the cache table and re-initialize the process to add them. What do you think? |
That would happen when changing the way how WPML is serving the languages only, right? |
Exactly! Only when enabling/disabling the "Use directory for default language" option. |
Yes, we should do that. |
…ry' into bug/5611-wpml-clean-root-directory
@CrochetFeve0251 The language-specific folders, e.g. However, any folders existing in and won't be removed even after clearing the cache for all languages using the admin bar menu. Steps to reproduce these:
I believe we should remove all folders when:
What do you think @piotrbak? |
@CrochetFeve0251 The cache is cleared when enabling/disabling WPML while "Use directory for default language" is enabled. 👍 I noticed the following related to preload while SEOPress was installed. When:
I debugged this and I can see that in step 2 we are getting URLs of sitemaps that don't exist which explains why URLs are not preloaded. Those URLs were the ones that correspond to those when WPML was enabled. Something similar happens with the default WordPress sitemap as well when disabling the "Use directory for default language" option. We only preload the additional language sitemap, e.g. for I'm not sure if this is an issue of the WPML + Preload combination and if it can be resolved by delaying the fetching of sitemaps. Unless @piotrbak thinks otherwise would you mind taking a look? 🙏 |
@vmanthos @CrochetFeve0251 Let's see the root cause and if there's a very easy workaround. If not, we can treat it as an edge case as disabling WPML is not something customers will be doing often. |
I think I maybe got an idea why. As the links stucture is change there is a huge change If I am not wrong we already implemented a solution we can reuse here. |
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.
Thank you for the continuous effort @CrochetFeve0251!
This is working as expected! 👍
TestRail report: testrail-report-497.pdf
Description
Clean root files when cleaning WPR cache.
Fixes #5611
Type of change
Please delete options that are not relevant.
Is the solution different from the one proposed during the grooming?
No.
How Has This Been Tested?
Checklist:
Please delete the options that are not relevant.