Skip to content

Commit

Permalink
WP Super Cache: Simplify the preload loop and improve stopping proced…
Browse files Browse the repository at this point in the history
…ures (#31022)

* Simplify the preload loop

* changelog

* Show the "next preload" message any time it's needed.
Not just when it's close to that preload time.

* Remove div tags, not needed

* Use wpsc_is_preload_active() for stopping

Add checks to that function for the stop_preload flag, and if the
mutex file is missing then return false.

* Simplify stopping the preload. Remove the "preload_cache_stop" flag.

* No need for two "stop" flags to stop the preload.
* Reset the settings immediately, for quicker shutdown.

* Catch "stop preload" flag first, then (corrected) mutex check

* This will abort the preload right at the start of the function, if it's cancelled.

* Reset settings if preload cancelled, instead of scheduling new task

* Fix translators explanation.

* No need for $mutex here, only used once

* Fix missing variable

* Merge with changes in #31017

* Use wpsc_is_preload_active() for "Preload now" button check

* Set idle status on cancel, and remove "almost cancelled" message.

There's a check on the STOP condition in each loop of the preload, so
it stops very quickly now. No configuration or temp files are updated.

* Check the preload counter for the "post" loop as well

* Fix typo in option name

---------

Co-authored-by: Peter Petrov <[email protected]>
  • Loading branch information
donnchawp and dilirity authored Jun 22, 2023
1 parent 2cdf41c commit b127b8c
Show file tree
Hide file tree
Showing 3 changed files with 197 additions and 122 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

WP Super Cache: simplify the preload loop and improve stopping procedures.
4 changes: 1 addition & 3 deletions projects/plugins/super-cache/partials/preload.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,10 @@
echo '<option value="less" ' . selected( 'less', $wp_cache_preload_email_volume ) . '>' . esc_html__( 'Less emails, 1 at the start and 1 at the end of preloading all posts.', 'wp-super-cache' ) . '</option>';
echo "</select>";

$preload_counter = get_option( 'preload_cache_counter' );
if (
wp_next_scheduled( 'wp_cache_preload_hook' )
|| wp_next_scheduled( 'wp_cache_full_preload_hook' )
|| ( is_array( $preload_counter ) && $preload_counter['c'] > 0 )
|| get_transient( 'taxonomy_preload' )
|| wpsc_is_preload_active()
) {
$currently_preloading = true;
}
Expand Down
Loading

0 comments on commit b127b8c

Please sign in to comment.