Commit 03c97413 authored by lucha's avatar lucha

[auto] plugin: wp-super-cache 1.5.8

parent 6e8ea2cb
......@@ -34,8 +34,8 @@ if ($arr_of_cnames[0] == '') $arr_of_cnames = array();
* @return Boolean true if to exclude given match from rewriting
*/
function scossdl_off_exclude_match($match, $excludes) {
foreach ($excludes as $badword) {
if (stristr($match, $badword) != false) {
foreach( $excludes as $badword ) {
if ( ! empty( $badword ) && stripos( $match, $badword ) !== false ) {
return true;
}
}
......@@ -160,13 +160,14 @@ function scossdl_off_options() {
$example_cdn_uri = get_option('ossdl_off_cdn_url') == get_option( 'siteurl' ) ? $example_cdn_uri : get_option('ossdl_off_cdn_url');
$example_cdn_uri .= '/wp-includes/js/jquery/jquery-migrate.js';
$example_cdn_uri = esc_url( $example_cdn_uri );
?>
<p><?php _e( 'Your website probably uses lots of static files. Image, Javascript and CSS files are usually static files that could just as easily be served from another site or CDN. Therefore, this plugin replaces any links in the <code>wp-content</code> and <code>wp-includes</code> directories (except for PHP files) on your site with the URL you provide below. That way you can either copy all the static content to a dedicated host or mirror the files to a CDN by <a href="https://knowledgelayer.softlayer.com/faq/how-does-origin-pull-work" target="_blank">origin pull</a>.', 'wp-super-cache' ); ?></p>
<p><?php printf( __( '<strong style="color: red">WARNING:</strong> Test some static urls e.g., %s to ensure your CDN service is fully working before saving changes.', 'wp-super-cache' ), '<code>' . $example_cdn_uri . '</code>' ); ?></p>
<p><?php printf( __( '<strong style="color: red">WARNING:</strong> Test some static urls e.g., %s to ensure your CDN service is fully working before saving changes.', 'wp-super-cache' ), '<code>' . esc_html( $example_cdn_uri ) . '</code>' ); ?></p>
<?php if ( $ossdl_off_blog_url != get_home_url() ) { ?>
<p><?php printf( __( '<strong style="color: red">WARNING:</strong> Your siteurl and homeurl are different. The plugin is using %s as the homepage URL of your site but if that is wrong please use the filter "ossdl_off_blog_url" to fix it.', 'wp-super-cache' ), '<code>' . $ossdl_off_blog_url . '</code>' ); ?></p>
<?php } ?>
<p><?php printf( __( '<strong style="color: red">WARNING:</strong> Your siteurl and homeurl are different. The plugin is using %s as the homepage URL of your site but if that is wrong please use the filter "ossdl_off_blog_url" to fix it.', 'wp-super-cache' ), '<code>' . esc_html( $ossdl_off_blog_url ) . '</code>' ); ?></p>
<?php } ?>
<p><?php _e( 'You can define different CDN URLs for each site on a multsite network.', 'wp-super-cache' ); ?></p>
<p><form method="post" action="">
......@@ -189,7 +190,7 @@ function scossdl_off_options() {
<th scope="row"><label for="ossdl_off_cdn_url"><?php _e( 'Off-site URL', 'wp-super-cache' ); ?></label></th>
<td>
<input type="text" name="ossdl_off_cdn_url" value="<?php echo esc_url( get_option( 'ossdl_off_cdn_url' ) ); ?>" size="64" class="regular-text code" /><br />
<span class="description"><?php printf( __( 'The new URL to be used in place of %1$s for rewriting. No trailing <code>/</code> please.<br />Example: <code>%2$s</code>.', 'wp-super-cache' ), get_option( 'siteurl' ), $example_cdn_uri ); ?></span>
<span class="description"><?php printf( __( 'The new URL to be used in place of %1$s for rewriting. No trailing <code>/</code> please.<br />Example: <code>%2$s</code>.', 'wp-super-cache' ), esc_html( get_option( 'siteurl' ) ), esc_html( $example_cdn_uri ) ); ?></span>
</td>
</tr>
<tr valign="top">
......@@ -210,7 +211,7 @@ function scossdl_off_options() {
<th scope="row"><label for="ossdl_cname"><?php _e( 'Additional CNAMES', 'wp-super-cache' ); ?></label></th>
<td>
<input type="text" name="ossdl_cname" value="<?php echo esc_attr( get_option( 'ossdl_cname' ) ); ?>" size="64" class="regular-text code" /><br />
<span class="description"><?php printf( __( 'These <a href="http://en.wikipedia.org/wiki/CNAME_record">CNAMES</a> will be used in place of %1$s for rewriting (in addition to the off-site URL above). Use a comma as the delimiter. For pages with a large number of static files, this can improve browser performance. CNAMEs may also need to be configured on your CDN.<br />Example: %2$s', 'wp-super-cache' ), get_option( 'siteurl' ), $example_cnames ); ?></span>
<span class="description"><?php printf( __( 'These <a href="http://en.wikipedia.org/wiki/CNAME_record">CNAMES</a> will be used in place of %1$s for rewriting (in addition to the off-site URL above). Use a comma as the delimiter. For pages with a large number of static files, this can improve browser performance. CNAMEs may also need to be configured on your CDN.<br />Example: %2$s', 'wp-super-cache' ), esc_html( get_option( 'siteurl' ) ), esc_html( $example_cnames ) ); ?></span>
</td>
</tr>
<tr valign="top">
......
=== WP Super Cache ===
Contributors: donncha, automattic, kraftbj
Tags: performance,caching,wp-cache,wp-super-cache,cache
Tested up to: 4.8.2
Stable tag: 1.5.7.1
Tested up to: 4.8.3
Stable tag: 1.5.8
Requires at least: 3.0
A very fast caching engine for WordPress that produces static html files.
......@@ -53,9 +53,24 @@ Interested in translating WP Super Cache to your language? See the [translation
The cache directory, usually wp-content/cache/ is only for temporary files. Do not ever put important files or symlinks to important files or directories in that directory. They will be deleted if the plugin has write access to them.
== Upgrade Notice ==
Fixes fatal error for older versions of WP and corrupted config file issues.
Many bug fixes
== Changelog ==
= 1.5.8 =
* PHP 7 fixes. (#429)
* Fix debug comments checkbox. (#433)
* Only register uninstall function in admin pages to save queries. (#430)
* Check that wp-cache-phase1.php is loaded before saving settings page. (#428)
* If a url has a "?" in it then don't delete the associated cache. It'll delete the whole cache after stripping out ?... part. (#427 & #420)
* Allow static functions in classes to be used in cacheactions. (#425)
* Don't make AJAX requests anonymous. (#423)
* Fixed link to chmod explanation. (#421)
* Add more escaping to the CDN settings page. (#416)
* Use SERVER_PROTOCOL to determine http protocol. (#412 & #413)
* If preload stalls only send one email per day, but do display an admin notice. (#432)
* Fixed more PHP warnings in #438 and #437
* Hide mod_rewrite warnings for Nginx users. #434
= 1.5.7.1 =
* If the HTTP HOST is empty then don't use it in strpos to avoid a PHP warning. (#408)
* Don't preload posts with permalinks that contain rejected strings. (#407)
......
......@@ -42,11 +42,10 @@ class WP_Super_Cache_Rest_Get_Settings extends WP_REST_Controller {
$settings[ $name ] = get_option( $map['option'] );
} elseif ( isset( $map['global'] ) ) {
$global_var = $map['global'];
if ( false == isset( $$global_var ) ) {
if ( false == isset( $GLOBALS[ $map[ 'global' ] ] ) ) {
$settings[ $name ] = false;
} else {
$settings[ $name ] = $$global_var;
$settings[ $name ] = $GLOBALS[ $map[ 'global' ] ];
}
}
}
......
......@@ -502,9 +502,7 @@ class WP_Super_Cache_Rest_Update_Settings extends WP_REST_Controller {
);
foreach ( $advanced_settings as $setting ) {
global ${$setting};
$value = ( isset( $$setting ) && $$setting == 1 ) ? 1 : 0;
$value = ( isset( $GLOBALS[ $setting ] ) && $GLOBALS[ $setting ] == 1 ) ? 1 : 0;
$this->set_value_by_key( $value, $setting );
}
}
......@@ -529,9 +527,8 @@ class WP_Super_Cache_Rest_Update_Settings extends WP_REST_Controller {
);
foreach ( $all_time_settings as $time_setting ) {
global ${$time_setting};
if ( false == isset( $_POST[ $time_setting ] ) || $$time_setting == $_POST[ $time_setting ] ) {
$_POST[ $time_setting ] = $$time_setting; // fill in the potentially missing fields before updating GC settings.
if ( false == isset( $_POST[ $time_setting ] ) || $GLOBALS[ $time_setting ] == $_POST[ $time_setting ] ) {
$_POST[ $time_setting ] = $GLOBALS[ $time_setting ]; // fill in the potentially missing fields before updating GC settings.
}
}
......@@ -590,8 +587,7 @@ class WP_Super_Cache_Rest_Update_Settings extends WP_REST_Controller {
foreach ( $all_preload_settings as $key => $original ) {
if ( ! isset( $_POST[ $key ] ) ) {
global ${$original};
$_POST[ $original ] = $$original;
$_POST[ $original ] = $GLOBALS[ $original ];
} else {
$_POST[ $original ] = $_POST[ $key ];
if ( $key !== 'preload_interval' && ( $_POST[ $key ] === 0 || $_POST[ $key ] === false ) ) {
......@@ -649,8 +645,7 @@ class WP_Super_Cache_Rest_Update_Settings extends WP_REST_Controller {
}
$_POST[ 'wp_cache_debug' ] = 1;
} else {
global $$setting;
$_POST[ $setting ] = $$setting;
$_POST[ $setting ] = $GLOBALS[ $setting ];
}
}
global $valid_nonce;
......
......@@ -101,4 +101,5 @@ $wpsc_served_header = false;
$cache_gc_email_me = 0;
$wpsc_save_headers = 0;
$cache_schedule_interval = 'daily';
$wp_super_cache_comments = 1;
?>
......@@ -283,7 +283,7 @@ function wp_cache_serve_cache_file() {
}
$local_mod_time = gmdate("D, d M Y H:i:s",filemtime( $file )).' GMT';
if ( !is_null($remote_mod_time) && $remote_mod_time == $local_mod_time ) {
header("HTTP/1.0 304 Not Modified");
header( $_SERVER[ 'SERVER_PROTOCOL' ] . " 304 Not Modified" );
exit();
}
header( 'Last-Modified: ' . $local_mod_time );
......@@ -454,11 +454,7 @@ function do_cacheaction( $action, $value = '' ) {
if( array_key_exists($action, $wp_supercache_actions) && is_array( $wp_supercache_actions[ $action ] ) ) {
$actions = $wp_supercache_actions[ $action ];
foreach( $actions as $func ) {
if ( is_array( $func ) ) {
$value = $func[0]->{$func[1]}( $value );
} else {
$value = $func( $value );
}
$value = call_user_func_array( $func, array( $value ) );
}
}
......@@ -572,6 +568,15 @@ function wp_cache_debug( $message, $level = 1 ) {
// path to the log file in the cache folder
$log_file = $cache_path . str_replace('/', '', str_replace('..', '', $wp_cache_debug_log));
if ( ! file_exists( $log_file ) && function_exists( 'wpsc_create_debug_log' ) ) {
global $wp_cache_debug_username;
if ( ! isset( $wp_cache_debug_username ) ) {
$wp_cache_debug_username = '';
}
wpsc_create_debug_log( $wp_cache_debug_log, $wp_cache_debug_username );
}
error_log( $log_message, 3, $log_file );
}
......@@ -868,7 +873,7 @@ function get_oc_key( $url = false ) {
}
function wp_supercache_cache_for_admins() {
if ( isset( $_GET[ 'preview' ] ) || function_exists( "is_admin" ) && is_admin() )
if ( isset( $_GET[ 'preview' ] ) || function_exists( "is_admin" ) && is_admin() || defined( 'DOING_AJAX' ) )
return true;
if ( false == do_cacheaction( 'wp_supercache_remove_cookies', true ) )
......@@ -953,4 +958,113 @@ function wpsc_get_protected_directories() {
);
}
function wpsc_create_debug_log( $filename = '', $username = '' ) {
global $cache_path, $wp_cache_debug_username, $wp_cache_debug_log;
if ( $filename != '' ) {
$wp_cache_debug_log = $filename;
} else {
$wp_cache_debug_log = md5( time() + mt_rand() ) . ".php";
}
if ( $username != '' ) {
$wp_cache_debug_username = $username;
} else {
$wp_cache_debug_username = md5( time() + mt_rand() );
}
$msg = '
if ( !isset( $_SERVER[ "PHP_AUTH_USER" ] ) || ( $_SERVER[ "PHP_AUTH_USER" ] != "' . $wp_cache_debug_username . '" && $_SERVER[ "PHP_AUTH_PW" ] != "' . $wp_cache_debug_username . '" ) ) {
header( "WWW-Authenticate: Basic realm=\"WP-Super-Cache Debug Log\"" );
header("HTTP/1.0 401 Unauthorized");
echo "You must login to view the debug log";
exit;
}' . PHP_EOL;
$fp = fopen( $cache_path . $wp_cache_debug_log, 'w' );
if ( $fp ) {
fwrite( $fp, '<' . "?php\n" );
fwrite( $fp, $msg );
fwrite( $fp, '?' . "><pre>" . PHP_EOL );
fwrite( $fp, '<' . '?php // END HEADER ?' . '>' . PHP_EOL );
fclose( $fp );
wp_cache_setting( 'wp_cache_debug_log', $wp_cache_debug_log );
wp_cache_setting( 'wp_cache_debug_username', $wp_cache_debug_username );
}
$fp = fopen( $cache_path . 'view_' . $wp_cache_debug_log, 'w' );
if ( $fp ) {
fwrite( $fp, '<' . "?php" . PHP_EOL );
$msg .= '$debug_log = file( "./' . $wp_cache_debug_log . '" );
$start_log = 1 + array_search( "<" . "?php // END HEADER ?" . ">" . PHP_EOL, $debug_log );
if ( $start_log > 1 ) {
$debug_log = array_slice( $debug_log, $start_log );
}
?' . '><form action="" method="GET"><' . '?php
$checks = array( "wp-admin", "exclude_filter", "wp-content", "wp-json" );
foreach( $checks as $check ) {
if ( isset( $_GET[ $check ] ) ) {
$$check = 1;
} else {
$$check = 0;
}
}
if ( isset( $_GET[ "filter" ] ) ) {
$filter = htmlspecialchars( $_GET[ "filter" ] );
} else {
$filter = "";
}
unset( $checks[1] ); // exclude_filter
?' . '>
Exclude requests: <br />
<' . '?php foreach ( $checks as $check ) { ?>
<label><input type="checkbox" name="<' . '?php echo $check; ?' . '>" value="1" <' . '?php if ( $$check ) { echo "checked"; } ?' . '> /> <' . '?php echo $check; ?' . '></label><br />
<' . '?php } ?' . '>
<br />
Text to filter by:
<input type="text" name="filter" value="<' . '?php echo $filter; ?' . '>" /><br />
<input type="checkbox" name="exclude_filter" value="1" <' . '?php if ( $exclude_filter ) { echo "checked"; } ?' . '> /> Exclude by filter instead of include.<br />
<input type="submit" value="Submit" />
</form>
<' . '?php
foreach ( $debug_log as $t => $line ) {
foreach( $checks as $check ) {
if ( $$check && false !== strpos( $line, " /$check/" ) ) {
unset( $debug_log[ $t ] );
}
}
if ( $filter ) {
if ( false !== strpos( $line, $filter ) && $exclude_filter ) {
unset( $debug_log[ $t ] );
} elseif ( false === strpos( $line, $filter ) && ! $exclude_filter ) {
unset( $debug_log[ $t ] );
}
}
}
foreach( $debug_log as $line ) {
echo $line . "<br />";
}';
fwrite( $fp, $msg );
fclose( $fp );
}
return array( 'wp_cache_debug_log' => $wp_cache_debug_log, 'wp_cache_debug_username' => $wp_cache_debug_username );
}
function wpsc_delete_url_cache( $url ) {
if ( false !== strpos( $url, '?' ) ) {
wp_cache_debug( 'wpsc_delete_url_cache: URL contains the character "?". Not deleting URL: ' . $url );
return false;
}
$dir = str_replace( get_option( 'home' ), '', $url );
if ( $dir != '' ) {
$supercachedir = get_supercache_dir();
wpsc_delete_files( $supercachedir . $dir );
prune_super_cache( $supercachedir . $dir . '/page', true );
return true;
} else {
return false;
}
}
?>
......@@ -18,6 +18,8 @@ function wp_cache_phase2() {
wp_cache_debug( 'Setting up WordPress actions', 5 );
add_action( 'template_redirect', 'wp_super_cache_query_vars' );
add_filter( 'wp_redirect_status', 'wpsc_catch_http_status_code' );
add_filter( 'status_header', 'wpsc_catch_status_header', 10, 2 );
// Post ID is received
add_action('wp_trash_post', 'wp_cache_post_edit', 0);
......@@ -352,6 +354,7 @@ function wp_cache_writers_exit() {
function wp_super_cache_query_vars() {
global $wp_super_cache_query;
if ( is_search() )
$wp_super_cache_query[ 'is_search' ] = 1;
if ( is_page() )
......@@ -370,14 +373,57 @@ function wp_super_cache_query_vars() {
$wp_super_cache_query[ 'is_home' ] = 1;
if ( is_author() )
$wp_super_cache_query[ 'is_author' ] = 1;
if ( is_feed() || ( method_exists( $GLOBALS['wp_query'], 'get') && ( get_query_var( 'sitemap' ) || get_query_var( 'xsl' ) || get_query_var( 'xml_sitemap' ) ) ) )
// REST API
if ( ( defined( 'REST_REQUEST' ) && REST_REQUEST ) ||
( defined( 'JSON_REQUEST' ) && JSON_REQUEST ) ||
( defined( 'WC_API_REQUEST' ) && WC_API_REQUEST )
) {
$wp_super_cache_query[ 'is_rest' ] = 1;
}
// Feeds, sitemaps and robots.txt
if ( is_feed() ) {
$wp_super_cache_query[ 'is_feed' ] = 1;
if ( get_query_var( 'feed' ) == 'sitemap' ) {
$wp_super_cache_query[ 'is_sitemap' ] = 1;
}
} elseif ( get_query_var( 'sitemap' ) || get_query_var( 'xsl' ) || get_query_var( 'xml_sitemap' ) ) {
$wp_super_cache_query[ 'is_feed' ] = 1;
$wp_super_cache_query[ 'is_sitemap' ] = 1;
} elseif ( is_robots() ) {
$wp_super_cache_query[ 'is_robots' ] = 1;
}
// Reset everything if it's 404
if ( is_404() )
$wp_super_cache_query = array( 'is_404' => 1 );
return $wp_super_cache_query;
}
function wpsc_catch_status_header( $status_header, $code ) {
if ( $code != 200 )
wpsc_catch_http_status_code( $code );
return $status_header;
}
function wpsc_catch_http_status_code( $status ) {
global $wp_super_cache_query;
if ( in_array( intval( $status ), array( 301, 302, 303, 307 ) ) ) {
$wp_super_cache_query[ 'is_redirect' ] = 1;
} elseif ( $status == 304 ) {
$wp_super_cache_query[ 'is_304' ] = 1;
} elseif ( $status == 404 ) {
$wp_super_cache_query[ 'is_404' ] = 1;
}
return $status;
}
function wpsc_is_fatal_error() {
global $wp_super_cache_query;
......@@ -395,27 +441,26 @@ function wpsc_is_fatal_error() {
function wp_cache_ob_callback( $buffer ) {
global $wp_cache_pages, $wp_query, $wp_super_cache_query, $cache_acceptable_files, $wp_cache_no_cache_for_get, $wp_cache_object_cache, $wp_cache_request_uri, $do_rebuild_list, $wpsc_file_mtimes, $wpsc_save_headers, $super_cache_enabled;
$buffer = apply_filters( 'wp_cache_ob_callback_filter', $buffer );
$script = basename($_SERVER['PHP_SELF']);
$script = basename( $_SERVER[ 'PHP_SELF' ] );
// All the things that can stop a page being cached
$cache_this_page = true;
if ( wpsc_is_fatal_error() ) {
$cache_this_page = false;
wp_cache_debug( 'wp_cache_ob_callback: PHP Fatal error occurred. Not caching incomplete page.' );
} elseif ( empty( $wp_super_cache_query ) && !empty( $buffer ) && is_object( $wp_query ) ) {
$cache_this_page = false;
} elseif ( empty( $wp_super_cache_query ) && !empty( $buffer ) && is_object( $wp_query ) && method_exists( $wp_query, 'get' ) ) {
$wp_super_cache_query = wp_super_cache_query_vars();
} elseif ( empty( $wp_super_cache_query ) && function_exists( 'http_response_code' ) ) {
wpsc_catch_http_status_code( http_response_code() );
}
if ( empty( $wp_super_cache_query ) && function_exists( 'apply_filter' ) && apply_filter( 'wpsc_only_cache_known_pages', 1 ) ) {
$cache_this_page = false;
wp_cache_debug( 'wp_cache_ob_callback: wp_super_cache_query is empty. Not caching unknown page type. Return 0 to the wpsc_only_cache_known_pages filter to cache this page.' );
} elseif ( defined( 'DONOTCACHEPAGE' ) ) {
$buffer = apply_filters( 'wp_cache_ob_callback_filter', $buffer );
if ( defined( 'DONOTCACHEPAGE' ) ) {
wp_cache_debug( 'DONOTCACHEPAGE defined. Caching disabled.', 2 );
$cache_this_page = false;
} elseif ( $wp_cache_no_cache_for_get && false == empty( $_GET ) && false == defined( 'DOING_CRON' ) ) {
} elseif ( $wp_cache_no_cache_for_get && !empty( $_GET ) && false == defined( 'DOING_CRON' ) ) {
wp_cache_debug( "Non empty GET request. Caching disabled on settings page. " . json_encode( $_GET ), 1 );
$cache_this_page = false;
} elseif ( $_SERVER["REQUEST_METHOD"] == 'POST' || !empty( $_POST ) || get_option( 'gzipcompression' ) ) {
......@@ -469,6 +514,21 @@ function wp_cache_ob_callback( $buffer ) {
} elseif ( isset( $wp_cache_pages[ 'feed' ] ) && $wp_cache_pages[ 'feed' ] == 1 && isset( $wp_super_cache_query[ 'is_feed' ] ) ) {
wp_cache_debug( 'Not caching feed.', 2 );
$cache_this_page = false;
} elseif ( isset( $wp_super_cache_query[ 'is_rest' ] ) ) {
wp_cache_debug( 'REST API detected. Caching disabled.' );
$cache_this_page = false;
} elseif ( isset( $wp_super_cache_query[ 'is_robots' ] ) ) {
wp_cache_debug( 'robots.txt detected. Caching disabled.' );
$cache_this_page = false;
} elseif ( isset( $wp_super_cache_query[ 'is_redirect' ] ) ) {
wp_cache_debug( 'Redirect detected. Caching disabled.' );
$cache_this_page = false;
} elseif ( isset( $wp_super_cache_query[ 'is_304' ] ) ) {
wp_cache_debug( 'HTTP 304 (Not Modified) sent. Caching disabled.' );
$cache_this_page = false;
} elseif ( empty( $wp_super_cache_query ) && !empty( $buffer ) && apply_filters( 'wpsc_only_cache_known_pages', 1 ) ) {
wp_cache_debug( 'wp_cache_ob_callback: wp_super_cache_query is empty. Not caching unknown page type. Return 0 to the wpsc_only_cache_known_pages filter to cache this page.' );
$cache_this_page = false;
}
if ( isset( $wpsc_save_headers ) && $wpsc_save_headers )
......@@ -481,7 +541,7 @@ function wp_cache_ob_callback( $buffer ) {
$buffer = wp_cache_get_ob( $buffer );
wp_cache_shutdown_callback();
if ( isset( $wpsc_file_mtimes ) && is_array( $wpsc_file_mtimes ) && !empty( $wpsc_file_mtimes ) ) {
if ( !empty( $wpsc_file_mtimes ) && is_array( $wpsc_file_mtimes ) ) {
foreach( $wpsc_file_mtimes as $cache_file => $old_mtime ) {
if ( $old_mtime == @filemtime( $cache_file ) ) {
wp_cache_debug( "wp_cache_ob_callback deleting unmodified rebuilt cache file: $cache_file" );
......@@ -493,7 +553,7 @@ function wp_cache_ob_callback( $buffer ) {
}
return $buffer;
} else {
if ( is_array( $do_rebuild_list ) && false == empty( $do_rebuild_list ) ) {
if ( !empty( $do_rebuild_list ) && is_array( $do_rebuild_list ) ) {
foreach( $do_rebuild_list as $dir => $n ) {
if ( wp_cache_confirm_delete( $dir ) ) {
wp_cache_debug( 'wp_cache_ob_callback clearing rebuilt files in ' . $dir );
......@@ -566,7 +626,7 @@ function wp_cache_get_ob(&$buffer) {
global $cache_enabled, $cache_path, $cache_filename, $wp_start_time, $supercachedir;
global $new_cache, $wp_cache_meta, $cache_compression, $wp_super_cache_query;
global $wp_cache_gzip_encoding, $super_cache_enabled;
global $wp_cache_404, $gzsize, $supercacheonly;
global $gzsize, $supercacheonly;
global $blog_cache_dir, $wp_supercache_cache_list;
global $wp_cache_not_logged_in, $wp_cache_object_cache, $cache_max_time;
global $wp_cache_is_home, $wp_cache_front_page_checks, $wp_cache_mfunc_enabled;
......@@ -587,7 +647,7 @@ function wp_cache_get_ob(&$buffer) {
}
}
if ( $wp_cache_404 && false == apply_filters( 'wpsupercache_404', false ) ) {
if ( isset( $wp_super_cache_query[ 'is_404' ] ) && false == apply_filters( 'wpsupercache_404', false ) ) {
$new_cache = false;
if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) {
wp_cache_debug( "404 file not found not cached", 2 );
......@@ -597,13 +657,9 @@ function wp_cache_get_ob(&$buffer) {
if ( !preg_match( apply_filters( 'wp_cache_eof_tags', '/(<\/html>|<\/rss>|<\/feed>|<\/urlset|<\?xml)/i' ), $buffer ) ) {
$new_cache = false;
if( false === strpos( $_SERVER[ 'REQUEST_URI' ], 'robots.txt' ) ) {
if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) {
wp_cache_debug( "No closing html tag. Not caching.", 2 );
wp_cache_add_to_buffer( $buffer, "Page not cached by WP Super Cache. No closing HTML tag. Check your theme." );
}
} else {
wp_cache_debug( "robots.txt detected. Not caching.", 2 );
if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) {
wp_cache_debug( "No closing html tag. Not caching.", 2 );
wp_cache_add_to_buffer( $buffer, "Page not cached by WP Super Cache. No closing HTML tag. Check your theme." );
}
}
......@@ -1157,42 +1213,35 @@ function wp_cache_shutdown_callback() {
// correct Content-Type header for feeds, if we didn't see
// it in the response headers already. -- dougal
if ( isset( $wp_super_cache_query[ 'is_feed' ] ) ) {
$type = get_query_var('feed');
$type = str_replace('/','',$type);
switch ($type) {
case 'atom':
$value = "application/atom+xml";
break;
case 'rdf':
$value = "application/rdf+xml";
break;
case 'sitemap':
$value = "text/xml";
break;
case 'rss':
case 'rss2':
default:
if ( get_query_var( 'sitemap' ) || get_query_var( 'xsl' ) || get_query_var( 'xml_sitemap' ) ) {
wp_cache_debug( "wp_cache_shutdown_callback: feed sitemap detected: text/xml" );
$value = "text/xml";
} else {
$value = "application/rss+xml";
}
}
if ( isset( $wpsc_feed_ttl ) && $wpsc_feed_ttl == 1 ) {
$wp_cache_meta[ 'ttl' ] = 60;
if ( isset( $wp_super_cache_query[ 'is_sitemap' ] ) ) {
$type = 'sitemap';
$value = 'text/xml';
} else {
$type = get_query_var( 'feed' );
$type = str_replace('/','',$type);
switch ($type) {
case 'atom':
$value = 'application/atom+xml';
break;
case 'rdf':
$value = 'application/rdf+xml';
break;
case 'rss':
case 'rss2':
default:
$value = 'application/rss+xml';
}
}
$is_feed = true;
wp_cache_debug( "wp_cache_shutdown_callback: feed is type: $type - $value" );
} elseif ( get_query_var( 'sitemap' ) || get_query_var( 'xsl' ) || get_query_var( 'xml_sitemap' ) ) {
wp_cache_debug( "wp_cache_shutdown_callback: sitemap detected: text/xml" );
$value = "text/xml";
if ( isset( $wpsc_feed_ttl ) && $wpsc_feed_ttl == 1 ) {
$wp_cache_meta[ 'ttl' ] = 60;
}
$is_feed = true;
wp_cache_debug( "wp_cache_shutdown_callback: feed is type: $type - $value" );
} elseif ( isset( $wp_super_cache_query[ 'is_rest' ] ) ) { // json
$value = 'application/json';
} else { // not a feed
$value = get_option( 'html_type' );
if( $value == '' )
......@@ -1354,6 +1403,58 @@ function wp_cache_clear_cache( $blog_id = 0 ) {
}
}
function wpsc_delete_post_archives( $post ) {
$post = get_post( $post );
if ( ! is_object( $post ) ) {
return;
}
// Taxonomies - categories, tags, custom taxonomies
foreach( get_object_taxonomies( $post, 'objects' ) as $taxonomy ) {
if ( ! $taxonomy->public || ! $taxonomy->rewrite ) {
continue;
}
$terms = get_the_terms( $post->ID, $taxonomy->name );
if ( empty( $terms ) ) {
continue;
}
foreach( $terms as $term ) {
$term_url = get_term_link( $term, $taxonomy->name );
if ( is_wp_error( $term_url ) ) {
continue;
}
wpsc_delete_url_cache( $term_url );
wp_cache_debug( "wpsc_delete_post_archives: deleting cache of taxonomies: " . $term_url );
}
}