WordPress.org

Plugin Directory

Changeset 581261


Ignore:
Timestamp:
08/03/12 09:53:50 (21 months ago)
Author:
donncha
Message:

Added function to create garbage collection flag filename.

File:
1 edited

Legend:

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

    r579031 r581261  
    11951195} 
    11961196 
    1197 function maybe_stop_gc() { 
    1198     global $cache_path; 
    1199  
    1200     if ( @file_exists( $cache_path . 'wp_cache_gc.txt' ) ) { 
    1201         if ( filemtime( $cache_path . 'wp_cache_gc.txt' ) > 600 ) { 
    1202             @unlink( $cache_path . 'wp_cache_gc.txt' ); 
    1203             if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "maybe_stop_gc: GC flag found but deleted because it's older than 600 seconds.", 5 ); 
     1197function maybe_stop_gc( $flag ) { 
     1198 
     1199    if ( @file_exists( $flag ) ) { 
     1200        if ( time() - filemtime( $flag ) > 3600 ) { 
     1201            @unlink( $flag ); 
     1202            if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "maybe_stop_gc: GC flag found but deleted because it's older than 3600 seconds.", 5 ); 
    12041203            return false; 
    12051204        } else { 
     
    12121211    } 
    12131212} 
     1213function get_gc_flag() { 
     1214    global $cache_path; 
     1215    return $cache_path . strtolower( preg_replace( '!/:.*$!', '', str_replace( 'http://', '', str_replace( 'https://', '', get_option( 'home' ) ) ) ) ) . "_wp_cache_gc.txt"; 
     1216} 
    12141217 
    12151218function wp_cache_gc_cron() { 
     
    12221225    } 
    12231226 
    1224     if ( maybe_stop_gc() ) { 
     1227    $gc_flag = get_gc_flag(); 
     1228    if ( maybe_stop_gc( $gc_flag ) ) { 
    12251229        if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'GC flag found. GC cancelled.', 5 ); 
    12261230        return false; 
     
    12281232 
    12291233    update_option( 'wpsupercache_gc_time', time() );  
    1230     $fp = @fopen( $cache_path . "wp_cache_gc.txt", 'w' ); 
     1234    if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cache_gc_cron: Set GC Flag. ($gc_flag)", 5 ); 
     1235    $fp = @fopen( $gc_flag, 'w' ); 
    12311236    @fclose( $fp ); 
    12321237 
     
    12561261        wp_mail( get_option( 'admin_email' ), sprintf( __( '[%1$s] WP Super Cache GC Report', 'wp-super-cache' ), site_url() ), $msg ); 
    12571262    } 
    1258     @unlink( $cache_path . 'wp_cache_gc.txt' ); 
     1263    @unlink( $gc_flag ); 
    12591264    if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'GC completed. GC flag deleted.', 5 ); 
    12601265    schedule_wp_gc( 1 ); 
Note: See TracChangeset for help on using the changeset viewer.