Skip to content

Commit

Permalink
WP Super Cache: remove notification on preload restart (#35960)
Browse files Browse the repository at this point in the history
* Remove notifications that preload was restarted

* Restart preload after 5 seconds. No need to wait

* changelog

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/8066795891
  • Loading branch information
donnchawp authored and matticbot committed Feb 27, 2024
1 parent 2b59165 commit 7755b08
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 18 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ This is an alpha version! The changes listed here are not final.
- General: updated PHP requirement to PHP 7.0+
- General: update WordPress version requirements to WordPress 6.3.
- Updated package dependencies.
- WP Super Cache: remove notifications that preload started working again.

### Fixed
- Supercache: add "days" to "Next preload scheduled" message.
Expand Down
20 changes: 2 additions & 18 deletions wp-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -3665,28 +3665,12 @@ function option_preload_cache_counter( $value ) {

function check_up_on_preloading() {
$value = get_option( 'preload_cache_counter' );
if ( is_array( $value ) && $value[ 'c' ] > 0 && ( time() - $value[ 't' ] ) > 3600 && false == wp_next_scheduled( 'wp_cache_preload_hook' ) ) {
if ( is_admin() ) {
if ( get_option( 'wpsc_preload_restart_email' ) < ( time() - 86400 ) ) {
wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] Preload may have stalled.', 'wp-super-cache' ), get_bloginfo( 'url' ) ), sprintf( __( "Preload has been restarted.\n%s", 'wp-super-cache' ), admin_url( "options-general.php?page=wpsupercache" ) ) );
update_option( 'wpsc_preload_restart_email', time() );
}
add_action( 'admin_notices', 'wpsc_preload_restart_notice' );
}
wp_schedule_single_event( time() + 30, 'wp_cache_preload_hook' );
if ( is_array( $value ) && $value['c'] > 0 && ( time() - $value['t'] ) > 3600 && false === wp_next_scheduled( 'wp_cache_preload_hook' ) ) {
wp_schedule_single_event( time() + 5, 'wp_cache_preload_hook' );
}
}
add_action( 'init', 'check_up_on_preloading' ); // sometimes preloading stops working. Kickstart it.

function wpsc_preload_restart_notice() {

if ( false == wpsupercache_site_admin() )
return false;
if ( ! isset( $_GET[ 'page' ] ) || $_GET[ 'page' ] != 'wpsupercache' )
return false;
echo '<div class="notice notice-error"><p>' . __( 'Warning! WP Super Cache preload was interrupted but has been restarted.', 'wp-super-cache' ) . '</p></div>';
}

function wp_cache_disable_plugin( $delete_config_file = true ) {
global $wp_rewrite;
if ( file_exists( ABSPATH . 'wp-config.php') ) {
Expand Down

0 comments on commit 7755b08

Please sign in to comment.