Clear dynamic lists on WP Rocket update
Is your feature request related to a problem? Please describe. When having changes on files naming related to WP Rocket that require exclusions, the customer might wait up to one week to get the new exclusions updated.
Describe the solution you'd like To simplify the process without requiring conditional dynamic lists update, we can simply update them on WP Rocket update.
Describe alternatives you've considered N/A
Additional context Discussion - https://wp-media.slack.com/archives/C027UU7L8RL/p1724679004320979
So to add more details here,
When we update WPR plugin, we have a github workflow to update dynamic lists json files (this is the fallback) inside the plugin to be shipped with the new version but I think the problem here is that we cache those exclusions for one week in a transient and it won't be refreshed until it expires.
I only have a concern here, if we forced getting the dynamic lists after update this will add a load on our servers, mostly on the same time @DahmaniAdame added a valid comment on that point, that automatic updates are disabled by default so this will reduce the risk and I agree with that.
What I can think of here is with update we can change the expiry for those transients to be a random number between 1 and 24 hours (just an example)
OR
with update we can force updating the lists from the json file directly not just a fallback.
and I'm with the last one.
Acceptance Criteria:
- After the update we'll replace the dynamic JSON files placed in our config directory with the one that were placed in the zip archive
- We should respect the
WP_ROCKET_CONFIG_PATHconstant - The transient related to the lists expiration should be updated with the new date
Grooming
with wp_rocket_upgrade we will have a callback here, let's call it update_lists_from_files
and inside this new method, we will have the following code:
$this->dynamic_lists->update_lists_from_files();
then we will add this new method exactly here
public function update_lists_from_files() {
if ( $this->user->is_license_expired() ) {
return [
'success' => false,
'data' => '',
'message' => __( 'You need an active license to get the latest version of the lists from our server.', 'rocket' ),
];
}
foreach ( $this->providers as $provider ) {
// Here we delete the list transients
$provider->data_manager->remove_lists_cache();
// Here we get lists from json files and update the config file because transient is removed.
$provider->data_manager->get_lists();
}
}
Then we will create a new method here
public function remove_lists_cache(){
delete_transient( $this->get_cache_transient_name() );
}
Effort
[S]