-
Notifications
You must be signed in to change notification settings - Fork 227
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
Closes 5667 detect domain change #5688
Conversation
@CrochetFeve0251 I checked the PR on single (as in not multisite) sites. Both when changing www to non-www and vice versa, and when completely changing the domain name.
What's not happening, and I believe it should - it will also resolve the issue mentioned by @camilamadronero-zz here), is deleting the old cache folders. Can you please look into this? Also, take into consideration multisites. 🙏 |
@CrochetFeve0251 After changing the domain name, e.g. adding or removing PHP Fatal error: Uncaught TypeError: call_user_func_array(): Argument #1 ($callback) must be a valid callback, cannot access protected method WP_Rocket\Engine\Cache\AdminSubscriber::clear_cache() in /home/u923949912/domains/example.com/public_html/wp-includes/class-wp-hook.php:308
Stack trace:
#0 /home/u923949912/domains/example.com/public_html/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters()
#1 /home/u923949912/domains/example.com/public_html/wp-includes/plugin.php(517): WP_Hook->do_action()
#2 /home/u923949912/domains/example.com/public_html/wp-content/plugins/wp-rocket/inc/Engine/Admin/DomainChange/Subscriber.php(52): do_action()
#3 /home/u923949912/domains/example.com/public_html/wp-includes/class-wp-hook.php(308): WP_Rocket\Engine\Admin\DomainChange\Subscriber->maybe_launch_domain_changed()
#4 /home/u923949912/domains/example.com/public_html/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters()
#5 /home/u923949912/domains/example.com/public_html/wp-includes/plugin.php(517): WP_Hook->do_action()
#6 /home/u923949912/domains/example.com/public_html/wp-admin/admin.php(175): do_action()
#7 /home/u923949912/domains/example.com/public_html/wp-admin/plugins.php(10): require_once('/home/u92394991...')
#8 {main}
thrown in /home/u923949912/domains/example.com/public_html/wp-includes/class-wp-hook.php on line 308 After this, WordPress and WP Rocket is loading. Apart from the fatal error:
Can you please look into these? 🙏 |
@vmanthos the fatal could explain point 1. and 2. |
@CrochetFeve0251 Thank you for the fixes! All issues have been fixed except for the cache clearing (1.). When you have time, please check this. In the meantime, I'll continue exploratory testing. |
@CrochetFeve0251 Additionally to my previous comment, the following part should be updated: wp-rocket/inc/Engine/Cache/AdminSubscriber.php Lines 212 to 222 in 60d5f57
to match the logic here: wp-rocket/inc/functions/files.php Lines 250 to 264 in 0256f74
More info: #5854 |
@CrochetFeve0251 I continued exploratory testing on my Hostinger test server. They have a staging site feature where both the URL and the files paths are different compared to the production site. I pushed changes from staging to production and I found that they are not overwriting the value of I discovered that while they are overwriting the database, they won't do it for fields whose values contain the site's URL, e.g. To circumvent this we can save a hash of the URL of the site to What do you think? |
@CrochetFeve0251 On Hostinger, If there are changes to the staging site, e.g. a URLis add to the "Never Cache URLs", and our rewrite rules are in place, after the push those changes will not be reflected on the We should wp-rocket/inc/Engine/Cache/AdminSubscriber.php Lines 189 to 191 in 60d5f57
To sum up my findings so far:
|
@piotrbak I'm currently testing the latest commit to see if the reported issues are fixed. |
@piotrbak In multisites, the notice is still displayed but the button to regenerate the files and clear the cache is missing: Is this the expected outcome or shouldn't we display the notice at all? |
@CrochetFeve0251 Can you please check Remy's comment? Currently, the URL leads directly to the EN documentation, i.e. doesn't open in the Beacon, and will be the same regardless of the language the user is using, e.g. French. |
…hange' into enhancement/5667-detect-domain-change
…hange' into enhancement/5667-detect-domain-change
@CrochetFeve0251 The following issues have been fixed:
However, now the button to regenerate WP Rocket's files after a "push" isn't displayed. I believe it's related to the removal of Can you please look into this? 🙏 |
…hange' into enhancement/5667-detect-domain-change
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 @CrochetFeve0251 for your continuous effort on this PR.
This is working as expected! 🎉
TestRail report: testrail-report-511.pdf
@piotrbak @wp-media/php While testing another PR I found that the notice will be displayed when:
For WPML, we are already handling cache clearing when the specific option changes. With the notice displayed, the WMPL users who will click the "Regenerate WP Rocket configuration files now" button will have the cache cleared again and additionally, the How should we handle this? |
@vmanthos Are there any changes in our config file (new one generated when doing a visit) or .htaccess (change in rewrite rules after regenerating it) when changing this option in WPML? |
The only change I see is in the rewrite rules: |
@vmanthos So there's a value of doing it 🤔 |
If there is, then we missed something when we added the fix for this: In any case, this was a random finding and it would be good to investigate it further to make sure:
|
Probably the home_url or site_url is changed when doing this operation. Now I'm thinking, rewrite rules might not be working correctly for different languages if they're set to |
@CrochetFeve0251 Do you think it'd possible not to display the message based on the action that triggered it? |
@piotrbak what do you mean by action? I need some context. |
@CrochetFeve0251 It's about this one:
So, we're on the WPML Languages Settings page and we're changing this one: Pinging @vmanthos for confirmation |
Exactly. |
Description
This issue is related to the WP Rocket caching plugin for WordPress, where the user is requesting a feature that would display a notice after a site has been cloned to remind the user to deactivate and re-activate WP Rocket. The problem is that some users may not be aware that they need to deactivate WP Rocket before a migration or clone, and if they do not, it can lead to issues such as a non-cached or non-optimized site due to incorrect config files.
The solution proposed during grooming is to add a new subscriber class that detects a change of domain and launches the action
rocket_domain_changed
which will clear the cache, reset the preload cache table, and clear the config files.Fixes #5667
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?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Checklist:
Please delete the options that are not relevant.