WordPress.org

Plugin Directory

Changeset 792004


Ignore:
Timestamp:
10/22/13 20:26:27 (6 months ago)
Author:
donncha
Message:

Handle site migration more gracefully. Recreate advanced-cache.php and WPCACHEHOME if wp-cache-phase1.php wasn't loaded when admin loaded.

Location:
wp-super-cache/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wp-super-cache/trunk/wp-cache-phase1.php

    r703682 r792004  
    1919    $blog_cache_dir = $cache_path; 
    2020} 
     21 
     22$wp_cache_phase1_loaded = true; 
    2123 
    2224$mutex_filename  = 'wp_cache_mutex.lock'; 
  • wp-super-cache/trunk/wp-cache.php

    r750280 r792004  
    3535$wp_cache_config_file = WP_CONTENT_DIR . '/wp-cache-config.php'; 
    3636 
     37if ( !defined( 'WPCACHEHOME' ) ) { 
     38    define( 'WPCACHEHOME', dirname( __FILE__ ) . '/' ); 
     39    $wp_cache_config_file_sample = WPCACHEHOME . 'wp-cache-config-sample.php'; 
     40    $wp_cache_file = WPCACHEHOME . 'advanced-cache.php'; 
     41} elseif ( WPCACHEHOME != dirname( __FILE__ ) . '/' ) { 
     42    $wp_cache_config_file_sample = dirname( __FILE__ ) . '/wp-cache-config-sample.php'; 
     43    $wp_cache_file = dirname( __FILE__ ) . '/advanced-cache.php'; 
     44} else { 
     45    $wp_cache_config_file_sample = WPCACHEHOME . 'wp-cache-config-sample.php'; 
     46    $wp_cache_file = WPCACHEHOME . 'advanced-cache.php'; 
     47} 
     48 
    3749if( !@include($wp_cache_config_file) ) { 
    3850    get_wpcachehome(); 
     
    4355} 
    4456 
    45 $wp_cache_config_file_sample = WPCACHEHOME . 'wp-cache-config-sample.php'; 
    4657$wp_cache_link = WP_CONTENT_DIR . '/advanced-cache.php'; 
    47 $wp_cache_file = WPCACHEHOME . 'advanced-cache.php'; 
    4858 
    4959if( !defined( 'WP_CACHE' ) || ( defined( 'WP_CACHE' ) && constant( 'WP_CACHE' ) == false ) ) { 
     
    20852095    } 
    20862096 
    2087     $line = 'define( \'WPCACHEHOME\', \'' . constant( 'WPCACHEHOME' ) . '\' );'; 
     2097    $line = 'define( \'WPCACHEHOME\', \'' . dirname( __FILE__ ) . '/\' );'; 
    20882098    if ( !is_writeable_ACLSafe($global_config_file) || !wp_cache_replace_line('define *\( *\'WPCACHEHOME\'', $line, $global_config_file ) ) { 
    20892099            echo '<div id="message" class="updated fade"><h3>' . __( 'Warning', 'wp-super-cache' ) . "! <em>" . sprintf( __( 'Could not update %s!</em> WPCACHEHOME must be set in config file.', 'wp-super-cache' ), $global_config_file ) . "</h3>"; 
     
    26302640 
    26312641function wp_cache_admin_notice() { 
    2632     global $cache_enabled; 
     2642    global $cache_enabled, $wp_cache_phase1_loaded; 
    26332643    if( substr( $_SERVER["PHP_SELF"], -11 ) == 'plugins.php' && !$cache_enabled && function_exists( "admin_url" ) ) 
    26342644        echo '<div class="error"><p><strong>' . sprintf( __('WP Super Cache is disabled. Please go to the <a href="%s">plugin admin page</a> to enable caching.', 'wp-super-cache' ), admin_url( 'options-general.php?page=wpsupercache' ) ) . '</strong></p></div>'; 
    26352645 
    2636     if ( defined( 'ADVANCEDCACHEPROBLEM' ) ) 
    2637         echo '<div class="error"><p><strong>' . sprintf( __( 'Warning! WP Super Cache caching broken! The script advanced-cache.php could not load wp-cache-phase1.php.<br /><br />Please edit %1$s/advanced-cache.php and make sure the path to %2$swp-cache-phase1.php is correct.', 'wp-super-cache' ), WP_CONTENT_DIR, WPCACHEHOME ) . '</strong></p></div>'; 
     2646    if ( defined( 'ADVANCEDCACHEPROBLEM' ) || ( $cache_enabled && false == isset( $wp_cache_phase1_loaded ) ) ) { 
     2647        echo '<div class="error"><p>' . sprintf( __( 'Warning! WP Super Cache caching <strong>was</strong> broken but has been <strong>fixed</strong>! The script advanced-cache.php could not load wp-cache-phase1.php.<br /><br />The file %1$s/advanced-cache.php has been recreated and WPCACHEHOME fixed in your wp-config.php. Reload to hide this message.', 'wp-super-cache' ), WP_CONTENT_DIR ) . '</p></div>'; 
     2648        wp_cache_create_advanced_cache(); 
     2649    } 
    26382650} 
    26392651add_action( 'admin_notices', 'wp_cache_admin_notice' ); 
Note: See TracChangeset for help on using the changeset viewer.