Skip to content

Commit

Permalink
adding the grooming code
Browse files Browse the repository at this point in the history
  • Loading branch information
engahmeds3ed committed Sep 14, 2023
1 parent 98b0513 commit 4d07ba3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
16 changes: 15 additions & 1 deletion inc/Engine/Cache/PurgeActionsSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static function get_subscribed_events() {
],
'rocket_rucss_complete_job_status' => [ 'purge_url_cache', 100 ],
'rocket_rucss_after_clearing_usedcss' => 'purge_url_cache',
'rocket_after_save_dynamic_lists' => 'purge_cache',
'rocket_after_save_dynamic_lists' => 'purge_cache_after_saving_dynamic_lists',
'update_option_' . $slug => [ 'purge_cache_reject_uri_partially', 10, 2 ],
'update_option_blog_public' => 'purge_cache',
];
Expand Down Expand Up @@ -179,4 +179,18 @@ public function purge_cache() {
public function purge_cache_reject_uri_partially( array $old_value, array $value ): void {
$this->purge->purge_cache_reject_uri_partially( $old_value, $value );
}

/**
* Purge cache after saving dynamic lists.
*
* @param bool $should_purge Should purge or not.
*
* @return void
*/
public function purge_cache_after_saving_dynamic_lists( $should_purge = true ) {
if ( ! $should_purge ) {
return;
}
$this->purge_cache();
}
}
9 changes: 6 additions & 3 deletions inc/Engine/Optimization/DynamicLists/DynamicLists.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,9 @@ public function update_lists_from_remote() {
];
}

$response = [];
$success = false;
$response = [];
$success = false;
$should_purge = false;

foreach ( $this->providers as $provider ) {
$result = $provider->api_client->get_exclusions_list( $provider->data_manager->get_lists_hash() );
Expand Down Expand Up @@ -141,6 +142,8 @@ public function update_lists_from_remote() {
'data' => '',
'message' => __( 'Lists are successfully updated.', 'rocket' ),
];

$should_purge |= $provider->clear_cache ?? true;
}

if ( $success ) {
Expand All @@ -149,7 +152,7 @@ public function update_lists_from_remote() {
*
* @since 3.12.1
*/
do_action( 'rocket_after_save_dynamic_lists' );
do_action( 'rocket_after_save_dynamic_lists', $should_purge );
}

return $response;
Expand Down
1 change: 1 addition & 0 deletions inc/Engine/Optimization/DynamicLists/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public function register() {
'api_client' => $this->getContainer()->get( 'dynamic_lists_incompatible_plugins_lists_api_client' ),
'data_manager' => $this->getContainer()->get( 'dynamic_lists_incompatible_plugins_lists_data_manager' ),
'title' => __( 'Incompatible plugins Lists', 'rocket' ),
'clear_cache' => true,
],
];

Expand Down

0 comments on commit 4d07ba3

Please sign in to comment.