wp-rocket
wp-rocket copied to clipboard
Dismiss AccelerateWP htaccess rules leftovers on WP rocket activation
Before submitting an issue please check that you’ve completed the following steps:
- [x] Made sure you’re on the latest version
- [x] Used the search feature to ensure that the bug hasn’t been reported before
Describe the bug AccelerateWP might leave their htaccess rules after deactivation.
They use the same caching root folder as WP Rocket: /wp-content/cache/wp-rocket/
This will cause customers switching to WP Rocket to keep serving page cache even if WP Rocket is deactivated because of the leftover rules.
We can proceed to clear their htaccess rules on WP Rocket activation.
Something similar to the following:
https://github.com/wp-media/wp-rocket/blob/631fc90017805c8063340c771598b1ccec713772/inc/functions/htaccess.php#L51
Targeting these patterns:
$ftmp = preg_replace( '/\s*# BEGIN AccelerateWP.*# END AccelerateWP\s*?/isU', PHP_EOL . PHP_EOL, $ftmp );
$ftmp = preg_replace( '/\s*# BEGIN CloudLinux Site Optimization.*# END CloudLinux Site Optimization\s*?/isU', PHP_EOL . PHP_EOL, $ftmp );
To Reproduce Steps to reproduce the behavior: N/A
Expected behavior Make sure WP Rocket have caching served only when WP Rocket is activated.
Screenshots N/A
Additional context A/A
Acceptance Criteria (for WP Media team use only) Clear instructions for developers, to be added before the grooming
@DahmaniAdame Is this something we want to handle on our side? Erasing someone's htaccess rules during deactivation of our product might be risky, or at least may cause unwanted experience 🤔
Positive on this one:
$ftmp = preg_replace( '/\s*# BEGIN AccelerateWP.*# END AccelerateWP\s*?/isU', PHP_EOL . PHP_EOL, $ftmp );
It's the same rewrite rules as ours. The exact copy actually 😅 So, the risk is very neglectable that something can go wrong.
Not sure about this one:
$ftmp = preg_replace( '/\s*# BEGIN CloudLinux Site Optimization.*# END CloudLinux Site Optimization\s*?/isU', PHP_EOL . PHP_EOL, $ftmp );
But they dismiss it when their plugin is deactivated.
We can limit the behavior only if AccelerateWP is not activated.
If deactivated, the warning about not using both at the same time will be enough.
Alternatively, we can add a warning and prompt the user to clean up the leftovers on their own for it to be risk-free. We can maybe add a tracker to find out how many times it matched, and decide later if we do it automatically or not.
This is not something that can be implemented in the nearest future.