wp-rocket
wp-rocket copied to clipboard
Some transients aren't deleted after deleting WP Rocket
Before submitting an issue please check that you’ve completed the following steps:
- Made sure you’re on the latest version => 3.11.0.4
- Used the search feature to ensure that the bug hasn’t been reported before
Describe the bug Some WPR transients aren't deleted after deleting the plugin
To Reproduce Steps to reproduce the behavior:
- Activate WPR and enable all options
- Deactivate the plugin
- Delete plugin
- Check transients
Expected behavior Transients are deleted when deleting the plugin
Screenshots
If applicable, add screenshots to help explain your problem.
Backlog Grooming (for WP Media dev team use only)
- [ ] Reproduce the problem
- [ ] Identify the root cause
- [ ] Scope a solution
- [ ] Estimate the effort
Additionally to the transients that Mai listed this one is not deleted as well:
wpr_dashboard_seen_
The same goes for the following option:
rocket_cache_dir_size_check
This too wpr_dynamic_lists_delayjs
is not deleted
The following as well:
-
timeout_wp_rocket_pricing
-
wp_rocket_pricing
-
wp_rocket_last_base_url
-
timeout_rocket_mod_pagespeed_enabled
cloudflare_update_settings
isn't deleted as well.
https://github.com/wp-media/wp-rocket/blob/8befdf3f22a901749dfcdd6a1a0c980530f0d120/inc/Addon/Cloudflare/Subscriber.php#L559
https://github.com/wp-media/wp-rocket/blob/8befdf3f22a901749dfcdd6a1a0c980530f0d120/inc/Addon/Cloudflare/Subscriber.php#L574
Reproduce the problem ✅
Did not reproduce the problem as the cause is clearly visible in the code.
Identify the root cause ✅
The identified transients in the screenshot above are not added to the array here: https://github.com/wp-media/wp-rocket/blob/8b64400a9c36ec5c0a26df238946cea389fc2a34/inc/Engine/WPRocketUninstall.php#L47
Scope a solution ✅
Add the following transients to the array here
rocket_rucss_processing
rocket_mod_pagespeed_enabled
wp_rocket_pricing
rocket_get_refreshed_fragments_cache
For dynamic transients like wpr_dashboard_seen_
and _cloudflare_update_settings
we can delete them by doing a direct query with a wildcard on the db using wpdb
Estimate the effort ✅ [XS]
Is the use of wpdb
and wildcard
a good idea ?
We aren't using much wpdb
within the plugin itself, and the wildcard
is a bit too general, even tho names of the transient are specific.
For the _cloudflare_update_settings
transient, I thought about this solution:
foreach (get_users() as $user) {
delete_transient($user->ID . '_cloudflare_update_settings');
}
But in case of a website with tons of users, it wouldn't be a good idea to do a loop.
@Tabrisrp What do you think ? Is the use of wpdb
and a wildcard
okay ?
Yes it is, it is used in core for example to delete expired transients (https://developer.wordpress.org/reference/functions/delete_expired_transients/)
We can use the transient prefix + the name and it will only match what we need to delete.