Version Description
Download this release
Release Info
Developer | donncha |
Plugin | WP Super Cache |
Version | 1.6.0 |
Comparing to | |
See all releases |
Code changes from version 1.5.9 to 1.6.0
- plugins/jetpack.php +8 -0
- plugins/multisite.php +11 -9
- readme.txt +27 -4
- rest/class.wp-super-cache-rest-get-settings.php +2 -2
- rest/class.wp-super-cache-rest-update-settings.php +9 -2
- rest/class.wp-super-cache-settings-map.php +1 -1
- wp-cache-phase1.php +3 -1
- wp-cache-phase2.php +174 -126
- wp-cache.php +136 -71
plugins/jetpack.php
CHANGED
@@ -64,6 +64,14 @@ function wp_super_cache_jetpack_cookie_check( $cache_key ) {
|
|
64 |
}
|
65 |
}
|
66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
if ( function_exists( 'jetpack_is_mobile' ) ) {
|
68 |
if ( jetpack_is_mobile() ) {
|
69 |
return 'mobile';
|
64 |
}
|
65 |
}
|
66 |
|
67 |
+
if ( isset ( $_COOKIE['akm_mobile'] ) ) {
|
68 |
+
if ( $_COOKIE['akm_mobile'] == 'true' ) {
|
69 |
+
return 'mobile';
|
70 |
+
} elseif ( $_COOKIE['akm_mobile'] == 'false' ) {
|
71 |
+
return 'normal';
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
if ( function_exists( 'jetpack_is_mobile' ) ) {
|
76 |
if ( jetpack_is_mobile() ) {
|
77 |
return 'mobile';
|
plugins/multisite.php
CHANGED
@@ -7,7 +7,7 @@ if ( ( defined( 'WP_ALLOW_MULTISITE' ) && constant( 'WP_ALLOW_MULTISITE' ) === t
|
|
7 |
function wp_super_cache_multisite_init() {
|
8 |
add_filter( 'wpmu_blogs_columns', 'wp_super_cache_blogs_col' );
|
9 |
add_action( 'manage_sites_custom_column', 'wp_super_cache_blogs_field', 10, 2 );
|
10 |
-
add_action( 'init', 'wp_super_cache_override_on_flag' );
|
11 |
}
|
12 |
|
13 |
function wp_super_cache_blogs_col( $col ) {
|
@@ -20,18 +20,20 @@ function wp_super_cache_blogs_field( $name, $blog_id ) {
|
|
20 |
return false;
|
21 |
}
|
22 |
|
|
|
|
|
23 |
if ( isset( $_GET['id'], $_GET['action'], $_GET['_wpnonce'] )
|
24 |
-
&& $blog_id ===
|
25 |
&& wp_verify_nonce( $_GET['_wpnonce'], 'wp-cache' . $blog_id )
|
26 |
) {
|
27 |
-
if ( 'disable_cache' ===
|
28 |
-
add_blog_option( $
|
29 |
-
} elseif ( 'enable_cache' ===
|
30 |
-
delete_blog_option( $
|
31 |
}
|
32 |
}
|
33 |
|
34 |
-
if ( get_blog_option( $blog_id, 'wp_super_cache_disabled' )
|
35 |
echo '<a href="' . wp_nonce_url( add_query_arg( array( 'action' => 'enable_cache', 'id' => $blog_id ) ), 'wp-cache' . $blog_id ) . '">' . __( 'Enable', 'wp-super-cache' ) . '</a>';
|
36 |
} else {
|
37 |
echo '<a href="' . wp_nonce_url( add_query_arg( array( 'action' => 'disable_cache', 'id' => $blog_id ) ), 'wp-cache' . $blog_id ) . '">' . __( 'Disable', 'wp-super-cache' ) . '</a>';
|
@@ -39,7 +41,7 @@ function wp_super_cache_blogs_field( $name, $blog_id ) {
|
|
39 |
}
|
40 |
|
41 |
function wp_super_cache_multisite_notice() {
|
42 |
-
if (
|
43 |
echo '<div class="error"><p><strong>' . __( 'Caching has been disabled on this blog on the Network Admin Sites page.', 'wp-super-cache' ) . '</strong></p></div>';
|
44 |
}
|
45 |
}
|
@@ -50,7 +52,7 @@ function wp_super_cache_override_on_flag() {
|
|
50 |
return false;
|
51 |
}
|
52 |
|
53 |
-
if ( get_option( 'wp_super_cache_disabled' ) ) {
|
54 |
$cache_enabled = false;
|
55 |
$super_cache_enabled = false;
|
56 |
define( 'DONOTCACHEPAGE', 1 );
|
7 |
function wp_super_cache_multisite_init() {
|
8 |
add_filter( 'wpmu_blogs_columns', 'wp_super_cache_blogs_col' );
|
9 |
add_action( 'manage_sites_custom_column', 'wp_super_cache_blogs_field', 10, 2 );
|
10 |
+
add_action( 'init', 'wp_super_cache_override_on_flag', 9 );
|
11 |
}
|
12 |
|
13 |
function wp_super_cache_blogs_col( $col ) {
|
20 |
return false;
|
21 |
}
|
22 |
|
23 |
+
$blog_id = (int) $blog_id;
|
24 |
+
|
25 |
if ( isset( $_GET['id'], $_GET['action'], $_GET['_wpnonce'] )
|
26 |
+
&& $blog_id === filter_input( INPUT_GET, 'id', FILTER_VALIDATE_INT )
|
27 |
&& wp_verify_nonce( $_GET['_wpnonce'], 'wp-cache' . $blog_id )
|
28 |
) {
|
29 |
+
if ( 'disable_cache' === filter_input( INPUT_GET, 'action' ) ) {
|
30 |
+
add_blog_option( $blog_id, 'wp_super_cache_disabled', 1 );
|
31 |
+
} elseif ( 'enable_cache' === filter_input( INPUT_GET, 'action' ) ) {
|
32 |
+
delete_blog_option( $blog_id, 'wp_super_cache_disabled' );
|
33 |
}
|
34 |
}
|
35 |
|
36 |
+
if ( 1 === (int) get_blog_option( $blog_id, 'wp_super_cache_disabled' ) ) {
|
37 |
echo '<a href="' . wp_nonce_url( add_query_arg( array( 'action' => 'enable_cache', 'id' => $blog_id ) ), 'wp-cache' . $blog_id ) . '">' . __( 'Enable', 'wp-super-cache' ) . '</a>';
|
38 |
} else {
|
39 |
echo '<a href="' . wp_nonce_url( add_query_arg( array( 'action' => 'disable_cache', 'id' => $blog_id ) ), 'wp-cache' . $blog_id ) . '">' . __( 'Disable', 'wp-super-cache' ) . '</a>';
|
41 |
}
|
42 |
|
43 |
function wp_super_cache_multisite_notice() {
|
44 |
+
if ( 'wpsupercache' === filter_input( INPUT_GET, 'page' ) ) {
|
45 |
echo '<div class="error"><p><strong>' . __( 'Caching has been disabled on this blog on the Network Admin Sites page.', 'wp-super-cache' ) . '</strong></p></div>';
|
46 |
}
|
47 |
}
|
52 |
return false;
|
53 |
}
|
54 |
|
55 |
+
if ( 1 === (int) get_option( 'wp_super_cache_disabled' ) ) {
|
56 |
$cache_enabled = false;
|
57 |
$super_cache_enabled = false;
|
58 |
define( 'DONOTCACHEPAGE', 1 );
|
readme.txt
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
# WP Super Cache #
|
2 |
* Contributors: donncha, automattic, kraftbj
|
3 |
* Tags: performance, caching, wp-cache, wp-super-cache, cache
|
4 |
-
* Tested up to: 4.9.
|
5 |
-
* Stable tag: 1.
|
6 |
* Requires at least: 3.0
|
7 |
* Requires PHP: 5.2.4
|
8 |
* License: GPLv2 or later
|
@@ -136,7 +136,7 @@ If that doesn't work, add this line to your wp-config.php:
|
|
136 |
27. Use [Cron View](https://wordpress.org/plugins/cron-view/) to help diagnose garbage collection and preload problems. Use the plugin to make sure jobs are scheduled and for what time. Look for the wp_cache_gc and wp_cache_full_preload_hook jobs.
|
137 |
18. The error message, "WP Super Cache is installed but broken. The constant WPCACHEHOME must be set in the file wp-config.php and point at the WP Super Cache plugin directory." appears at the end of every page. You can delete wp-content/advanced-cache.php and reload the plugin settings page or edit wp-config.php and look for WPCACHEHOME and make sure it points at the wp-super-cache folder. This will normally be wp-content/plugins/wp-super-cache/ but you'll likely need the full path to that file (so it's easier to let the settings page fix it). If it is not correct the caching engine will not load.
|
138 |
19. If your server is running into trouble because of the number of semaphores used by the plugin it's because your users are using file locking which is not recommended (but is needed by a small number of users). You can globally disable file locking by defining the constant WPSC_DISABLE_LOCKING, or defining the constant WPSC_REMOVE_SEMAPHORE so that sem_remove() is called after every page is cached but that seems to cause problems for other processes requesting the same semaphore. Best to disable it.
|
139 |
-
|
140 |
|
141 |
## Installation ##
|
142 |
Install like any other plugin, directly from your plugins page but make sure you have custom permalinks enabled. Go to the plugin settings page at Settings->WP Super Cache and enable caching.
|
@@ -261,6 +261,29 @@ Your theme is probably responsive which means it resizes the page to suit whatev
|
|
261 |
|
262 |
## Changelog ##
|
263 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
264 |
### 1.5.9 ###
|
265 |
* Fixed fatal error if the debug log was deleted while debugging was enabled and a visitor came to the site.
|
266 |
* Fixed the dynamic caching test plugin because of PHP7 changes. Dynamic cache mode must be enabled now.
|
@@ -628,4 +651,4 @@ Your theme is probably responsive which means it resizes the page to suit whatev
|
|
628 |
|
629 |
|
630 |
## Upgrade Notice ##
|
631 |
-
|
1 |
# WP Super Cache #
|
2 |
* Contributors: donncha, automattic, kraftbj
|
3 |
* Tags: performance, caching, wp-cache, wp-super-cache, cache
|
4 |
+
* Tested up to: 4.9.5
|
5 |
+
* Stable tag: 1.6.0
|
6 |
* Requires at least: 3.0
|
7 |
* Requires PHP: 5.2.4
|
8 |
* License: GPLv2 or later
|
136 |
27. Use [Cron View](https://wordpress.org/plugins/cron-view/) to help diagnose garbage collection and preload problems. Use the plugin to make sure jobs are scheduled and for what time. Look for the wp_cache_gc and wp_cache_full_preload_hook jobs.
|
137 |
18. The error message, "WP Super Cache is installed but broken. The constant WPCACHEHOME must be set in the file wp-config.php and point at the WP Super Cache plugin directory." appears at the end of every page. You can delete wp-content/advanced-cache.php and reload the plugin settings page or edit wp-config.php and look for WPCACHEHOME and make sure it points at the wp-super-cache folder. This will normally be wp-content/plugins/wp-super-cache/ but you'll likely need the full path to that file (so it's easier to let the settings page fix it). If it is not correct the caching engine will not load.
|
138 |
19. If your server is running into trouble because of the number of semaphores used by the plugin it's because your users are using file locking which is not recommended (but is needed by a small number of users). You can globally disable file locking by defining the constant WPSC_DISABLE_LOCKING, or defining the constant WPSC_REMOVE_SEMAPHORE so that sem_remove() is called after every page is cached but that seems to cause problems for other processes requesting the same semaphore. Best to disable it.
|
139 |
+
20. Set the variable $htaccess_path in wp-config.php or wp-cache-config.php to the path of your global .htaccess if the plugin is looking for that file in the wrong directory. This might happen if you have WordPress installed in an unusual way.
|
140 |
|
141 |
## Installation ##
|
142 |
Install like any other plugin, directly from your plugins page but make sure you have custom permalinks enabled. Go to the plugin settings page at Settings->WP Super Cache and enable caching.
|
261 |
|
262 |
## Changelog ##
|
263 |
|
264 |
+
|
265 |
+
### 1.6.0 ###
|
266 |
+
* Fix issues in multisite plugin (#501)
|
267 |
+
* Fixes wp-cli plugin deactivate/activate (#499)
|
268 |
+
* Cleanup - change quotes. (#495)
|
269 |
+
* $htaccess_path defines the path to the global .htacess file. (#507)
|
270 |
+
* Fix 'cannot redeclare gzip_accepted()' (#511)
|
271 |
+
* Correct the renaming of tmp_wpcache_filename (removed unnecessary slash in path) which caused renaming to fail. (#516)
|
272 |
+
* Add check for Jetpack mobile theme cookie (#515)
|
273 |
+
* Optimize wp_cache_phase2 and create wpsc_register_post_hooks (#508)
|
274 |
+
* WPCACHEHOME has a trailing slash (#513)
|
275 |
+
* Cleanup cache enable/disable and update_mod_rewrite_rules (#500)
|
276 |
+
* Post Update now clears category cache (#519)
|
277 |
+
* Various fixes for saving the debug page form (#542)
|
278 |
+
* Expert-caching and empty parameters, like ?amp, should not serve cached page (#533)
|
279 |
+
* Tiny Yslow description fix (#527)
|
280 |
+
* Add ipad to mobile list (#525)
|
281 |
+
* Hide opcache_invalidate() warnings since it's disabled some places. (#543)
|
282 |
+
* Check that HTTP_REFERER exists before checking it. (#544)
|
283 |
+
* Replace Cron View" with WP Control because it's still updated. (#546)
|
284 |
+
* adding hook (wp_cache_cleared) for full cache purges (#537)
|
285 |
+
|
286 |
+
|
287 |
### 1.5.9 ###
|
288 |
* Fixed fatal error if the debug log was deleted while debugging was enabled and a visitor came to the site.
|
289 |
* Fixed the dynamic caching test plugin because of PHP7 changes. Dynamic cache mode must be enabled now.
|
651 |
|
652 |
|
653 |
## Upgrade Notice ##
|
654 |
+
Bug fix release
|
rest/class.wp-super-cache-rest-get-settings.php
CHANGED
@@ -23,7 +23,7 @@ class WP_Super_Cache_Rest_Get_Settings extends WP_REST_Controller {
|
|
23 |
}
|
24 |
|
25 |
if ( function_exists( "opcache_invalidate" ) ) {
|
26 |
-
opcache_invalidate( $wp_cache_config_file );
|
27 |
}
|
28 |
include( $wp_cache_config_file );
|
29 |
|
@@ -78,7 +78,7 @@ class WP_Super_Cache_Rest_Get_Settings extends WP_REST_Controller {
|
|
78 |
public function get_cache_type() {
|
79 |
global $wp_cache_config_file;
|
80 |
if ( function_exists( "opcache_invalidate" ) ) {
|
81 |
-
opcache_invalidate( $wp_cache_config_file );
|
82 |
}
|
83 |
include( $wp_cache_config_file );
|
84 |
|
23 |
}
|
24 |
|
25 |
if ( function_exists( "opcache_invalidate" ) ) {
|
26 |
+
@opcache_invalidate( $wp_cache_config_file );
|
27 |
}
|
28 |
include( $wp_cache_config_file );
|
29 |
|
78 |
public function get_cache_type() {
|
79 |
global $wp_cache_config_file;
|
80 |
if ( function_exists( "opcache_invalidate" ) ) {
|
81 |
+
@opcache_invalidate( $wp_cache_config_file );
|
82 |
}
|
83 |
include( $wp_cache_config_file );
|
84 |
|
rest/class.wp-super-cache-rest-update-settings.php
CHANGED
@@ -87,7 +87,11 @@ class WP_Super_Cache_Rest_Update_Settings extends WP_REST_Controller {
|
|
87 |
|
88 |
$set_method = method_exists( $this, 'set_' . $map['global'] ) ?
|
89 |
'set_' . $map['global'] : 'set_global';
|
90 |
-
|
|
|
|
|
|
|
|
|
91 |
}
|
92 |
|
93 |
if ( ! empty( $has_error ) ) {
|
@@ -604,7 +608,7 @@ class WP_Super_Cache_Rest_Update_Settings extends WP_REST_Controller {
|
|
604 |
wp_cache_setting( 'cache_page_secret', $cache_page_secret );
|
605 |
|
606 |
if ( function_exists( "opcache_invalidate" ) ) {
|
607 |
-
opcache_invalidate( $wp_cache_config_file );
|
608 |
}
|
609 |
}
|
610 |
wpsc_set_default_gc( true );
|
@@ -637,6 +641,9 @@ class WP_Super_Cache_Rest_Update_Settings extends WP_REST_Controller {
|
|
637 |
}
|
638 |
$_POST[ 'wp_cache_debug' ] = 1;
|
639 |
} else {
|
|
|
|
|
|
|
640 |
$_POST[ $setting ] = $GLOBALS[ $setting ];
|
641 |
}
|
642 |
}
|
87 |
|
88 |
$set_method = method_exists( $this, 'set_' . $map['global'] ) ?
|
89 |
'set_' . $map['global'] : 'set_global';
|
90 |
+
if ( $set_method == 'set_global' ) {
|
91 |
+
$has_error = call_user_func( array( $this, $set_method ), $key, $value );
|
92 |
+
} else {
|
93 |
+
$has_error = call_user_func( array( $this, $set_method ), $value );
|
94 |
+
}
|
95 |
}
|
96 |
|
97 |
if ( ! empty( $has_error ) ) {
|
608 |
wp_cache_setting( 'cache_page_secret', $cache_page_secret );
|
609 |
|
610 |
if ( function_exists( "opcache_invalidate" ) ) {
|
611 |
+
@opcache_invalidate( $wp_cache_config_file );
|
612 |
}
|
613 |
}
|
614 |
wpsc_set_default_gc( true );
|
641 |
}
|
642 |
$_POST[ 'wp_cache_debug' ] = 1;
|
643 |
} else {
|
644 |
+
if ( ! isset( $GLOBALS[ $setting ] ) ) {
|
645 |
+
$GLOBALS[ $setting ] = 0;
|
646 |
+
}
|
647 |
$_POST[ $setting ] = $GLOBALS[ $setting ];
|
648 |
}
|
649 |
}
|
rest/class.wp-super-cache-settings-map.php
CHANGED
@@ -236,7 +236,7 @@ class WP_Super_Cache_Settings_Map {
|
|
236 |
'global' => 'wp_super_cache_debug',
|
237 |
),
|
238 |
'wp_cache_debug_username' => array(
|
239 |
-
'
|
240 |
),
|
241 |
'wp_cache_debug_log' => array(
|
242 |
'global' => 'wp_cache_debug_log',
|
236 |
'global' => 'wp_super_cache_debug',
|
237 |
),
|
238 |
'wp_cache_debug_username' => array(
|
239 |
+
'get' => 'wpsc_debug_username',
|
240 |
),
|
241 |
'wp_cache_debug_log' => array(
|
242 |
'global' => 'wp_cache_debug_log',
|
wp-cache-phase1.php
CHANGED
@@ -1,6 +1,8 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
|
|
|
|
4 |
|
5 |
// error_reporting(E_ERROR | E_PARSE); // uncomment to debug this file!
|
6 |
if ( ! @include WP_CONTENT_DIR . '/wp-cache-config.php' ) {
|
1 |
<?php
|
2 |
|
3 |
+
if ( ! function_exists( 'wp_cache_phase2' ) ) {
|
4 |
+
require_once dirname( __FILE__ ) . '/wp-cache-phase2.php';
|
5 |
+
}
|
6 |
|
7 |
// error_reporting(E_ERROR | E_PARSE); // uncomment to debug this file!
|
8 |
if ( ! @include WP_CONTENT_DIR . '/wp-cache-config.php' ) {
|
wp-cache-phase2.php
CHANGED
@@ -53,12 +53,12 @@ function wp_cache_serve_cache_file() {
|
|
53 |
}
|
54 |
|
55 |
if ( wp_cache_user_agent_is_rejected() ) {
|
56 |
-
wp_cache_debug(
|
57 |
return false;
|
58 |
}
|
59 |
|
60 |
if ( $wp_cache_no_cache_for_get && false == empty( $_GET ) ) {
|
61 |
-
wp_cache_debug(
|
62 |
return false;
|
63 |
}
|
64 |
|
@@ -66,7 +66,7 @@ function wp_cache_serve_cache_file() {
|
|
66 |
|
67 |
if ( $wp_cache_object_cache && wp_cache_get_cookies_values() == '' ) {
|
68 |
if ( !empty( $_GET ) ) {
|
69 |
-
wp_cache_debug(
|
70 |
return false;
|
71 |
}
|
72 |
|
@@ -79,7 +79,7 @@ function wp_cache_serve_cache_file() {
|
|
79 |
$cache = wp_cache_get( $oc_key, 'supercache' );
|
80 |
$meta = json_decode( wp_cache_get( $meta_filename, 'supercache' ), true );
|
81 |
if ( is_array( $meta ) == false ) {
|
82 |
-
wp_cache_debug(
|
83 |
return true;
|
84 |
}
|
85 |
} elseif ( ( $cache_file && file_exists( $cache_file ) ) || file_exists( get_current_url_supercache_dir() . 'meta-' . $cache_filename ) ) {
|
@@ -87,7 +87,7 @@ function wp_cache_serve_cache_file() {
|
|
87 |
$cache_file = get_current_url_supercache_dir() . $cache_filename;
|
88 |
$meta_pathname = get_current_url_supercache_dir() . 'meta-' . $cache_filename;
|
89 |
} elseif ( !file_exists( $cache_file ) ) {
|
90 |
-
wp_cache_debug(
|
91 |
return false;
|
92 |
}
|
93 |
|
@@ -111,13 +111,13 @@ function wp_cache_serve_cache_file() {
|
|
111 |
wp_cache_debug( "No Super Cache file found for current URL: $file" );
|
112 |
return false;
|
113 |
} elseif ( false == empty( $_GET ) ) {
|
114 |
-
wp_cache_debug(
|
115 |
return false;
|
116 |
} elseif ( wp_cache_get_cookies_values() != '' ) {
|
117 |
-
wp_cache_debug(
|
118 |
return false;
|
119 |
} elseif ( isset( $wpsc_save_headers ) && $wpsc_save_headers ) {
|
120 |
-
wp_cache_debug(
|
121 |
return false;
|
122 |
}
|
123 |
|
@@ -199,7 +199,7 @@ function wp_cache_serve_cache_file() {
|
|
199 |
echo $cachefiledata;
|
200 |
exit();
|
201 |
} else {
|
202 |
-
wp_cache_debug(
|
203 |
return false;
|
204 |
}
|
205 |
}
|
@@ -208,7 +208,7 @@ function wp_cache_serve_cache_file() {
|
|
208 |
// Sometimes the gzip headers are lost. Make sure html returned isn't compressed!
|
209 |
if ( $cache_compression && $wp_cache_gzip_encoding && !in_array( 'Content-Encoding: ' . $wp_cache_gzip_encoding, $meta[ 'headers' ] ) ) {
|
210 |
$ungzip = true;
|
211 |
-
wp_cache_debug(
|
212 |
} else {
|
213 |
$ungzip = false;
|
214 |
}
|
@@ -226,30 +226,30 @@ function wp_cache_serve_cache_file() {
|
|
226 |
// attempt to uncompress the cached file just in case it's gzipped
|
227 |
$uncompressed = gzuncompress( $cache );
|
228 |
if ( $uncompressed ) {
|
229 |
-
wp_cache_debug(
|
230 |
$cache = $uncompressed;
|
231 |
unset( $uncompressed );
|
232 |
}
|
233 |
}
|
234 |
if ( isset( $meta[ 'dynamic' ] ) && $meta[ 'dynamic' ] ) {
|
235 |
-
wp_cache_debug(
|
236 |
echo do_cacheaction( 'wpsc_cachedata', $cache );
|
237 |
} else {
|
238 |
-
wp_cache_debug(
|
239 |
echo $cache;
|
240 |
}
|
241 |
-
wp_cache_debug(
|
242 |
die();
|
243 |
}
|
244 |
} else {
|
245 |
if ( isset( $meta[ 'dynamic' ] ) ) {
|
246 |
-
wp_cache_debug(
|
247 |
if ( $ungzip ) {
|
248 |
// attempt to uncompress the cached file just in case it's gzipped
|
249 |
$cache = wp_cache_get_legacy_cache( $cache_file );
|
250 |
$uncompressed = @gzuncompress( $cache );
|
251 |
if ( $uncompressed ) {
|
252 |
-
wp_cache_debug(
|
253 |
unset( $cache );
|
254 |
echo do_cacheaction( 'wpsc_cachedata', $uncompressed );
|
255 |
} else {
|
@@ -259,21 +259,23 @@ function wp_cache_serve_cache_file() {
|
|
259 |
echo do_cacheaction( 'wpsc_cachedata', wp_cache_get_legacy_cache( $cache_file ) );
|
260 |
}
|
261 |
} else {
|
262 |
-
wp_cache_debug(
|
263 |
if ( $ungzip ) {
|
264 |
$cache = wp_cache_get_legacy_cache( $cache_file );
|
265 |
$uncompressed = gzuncompress( $cache );
|
266 |
if ( $uncompressed ) {
|
267 |
-
wp_cache_debug(
|
268 |
echo $uncompressed;
|
269 |
} else {
|
|
|
270 |
echo $cache;
|
271 |
}
|
272 |
} else {
|
|
|
273 |
echo( wp_cache_get_legacy_cache( $cache_file ) );
|
274 |
}
|
275 |
}
|
276 |
-
wp_cache_debug(
|
277 |
die();
|
278 |
}
|
279 |
}
|
@@ -289,7 +291,7 @@ function wp_cache_postload() {
|
|
289 |
return true;
|
290 |
|
291 |
if ( isset( $wp_super_cache_late_init ) && true == $wp_super_cache_late_init ) {
|
292 |
-
wp_cache_debug(
|
293 |
add_action( 'init', 'wp_cache_late_loader', 9999 );
|
294 |
} else {
|
295 |
wp_super_cache_init();
|
@@ -298,7 +300,7 @@ function wp_cache_postload() {
|
|
298 |
}
|
299 |
|
300 |
function wp_cache_late_loader() {
|
301 |
-
wp_cache_debug(
|
302 |
wp_cache_serve_cache_file();
|
303 |
wp_cache_phase2();
|
304 |
}
|
@@ -384,11 +386,11 @@ function wp_cache_check_mobile( $cache_key ) {
|
|
384 |
// allow plugins to short circuit mobile check. Cookie, extra UA checks?
|
385 |
switch( do_cacheaction( 'wp_cache_check_mobile', $cache_key ) ) {
|
386 |
case "normal":
|
387 |
-
wp_cache_debug(
|
388 |
return $cache_key;
|
389 |
break;
|
390 |
case "mobile":
|
391 |
-
wp_cache_debug(
|
392 |
return $cache_key . "-mobile";
|
393 |
break;
|
394 |
}
|
@@ -398,7 +400,7 @@ function wp_cache_check_mobile( $cache_key ) {
|
|
398 |
}
|
399 |
|
400 |
if ( do_cacheaction( 'disable_mobile_check', false ) ) {
|
401 |
-
wp_cache_debug(
|
402 |
return $cache_key;
|
403 |
}
|
404 |
|
@@ -406,7 +408,7 @@ function wp_cache_check_mobile( $cache_key ) {
|
|
406 |
$user_agent = strtolower( $_SERVER['HTTP_USER_AGENT'] );
|
407 |
foreach ($browsers as $browser) {
|
408 |
if ( strstr( $user_agent, trim( strtolower( $browser ) ) ) ) {
|
409 |
-
wp_cache_debug(
|
410 |
return $cache_key . '-' . wp_cache_mobile_group( $user_agent );
|
411 |
}
|
412 |
}
|
@@ -419,7 +421,7 @@ function wp_cache_check_mobile( $cache_key ) {
|
|
419 |
$browsers = explode( ',', $wp_cache_mobile_prefixes );
|
420 |
foreach ($browsers as $browser_prefix) {
|
421 |
if ( substr($user_agent, 0, 4) == $browser_prefix ) {
|
422 |
-
wp_cache_debug(
|
423 |
return $cache_key . '-' . $browser_prefix;
|
424 |
}
|
425 |
}
|
@@ -631,12 +633,12 @@ function wpsc_is_in_cache_directory( $directory ) {
|
|
631 |
static $rp_cache_path = '';
|
632 |
|
633 |
if ( $directory == '' ) {
|
634 |
-
wp_cache_debug(
|
635 |
return false;
|
636 |
}
|
637 |
|
638 |
if ( $cache_path == '' ) {
|
639 |
-
wp_cache_debug(
|
640 |
return false;
|
641 |
}
|
642 |
|
@@ -645,14 +647,14 @@ function wpsc_is_in_cache_directory( $directory ) {
|
|
645 |
}
|
646 |
|
647 |
if ( ! $rp_cache_path ) {
|
648 |
-
wp_cache_debug(
|
649 |
return false;
|
650 |
}
|
651 |
|
652 |
$directory = wpsc_get_realpath( $directory );
|
653 |
|
654 |
if ( ! $directory ) {
|
655 |
-
wp_cache_debug(
|
656 |
return false;
|
657 |
}
|
658 |
|
@@ -668,7 +670,7 @@ function wpsc_delete_files( $dir, $delete = true ) {
|
|
668 |
static $protected = '';
|
669 |
|
670 |
if ( $dir == '' ) {
|
671 |
-
wp_cache_debug(
|
672 |
return false;
|
673 |
}
|
674 |
|
@@ -682,7 +684,7 @@ function wpsc_delete_files( $dir, $delete = true ) {
|
|
682 |
|
683 |
$dir = wpsc_get_realpath( $dir );
|
684 |
if ( ! $dir ) {
|
685 |
-
wp_cache_debug(
|
686 |
return false;
|
687 |
}
|
688 |
|
@@ -716,7 +718,7 @@ function get_all_supercache_filenames( $dir = '' ) {
|
|
716 |
|
717 |
$dir = wpsc_get_realpath( $dir );
|
718 |
if ( ! $dir ) {
|
719 |
-
wp_cache_debug(
|
720 |
return array();
|
721 |
}
|
722 |
|
@@ -832,7 +834,7 @@ function wp_cache_confirm_delete( $dir ) {
|
|
832 |
$dir = wpsc_get_realpath( $dir );
|
833 |
|
834 |
if ( ! $dir ) {
|
835 |
-
wp_cache_debug(
|
836 |
return false;
|
837 |
}
|
838 |
|
@@ -886,6 +888,14 @@ function wpsc_get_protected_directories() {
|
|
886 |
);
|
887 |
}
|
888 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
889 |
function wpsc_create_debug_log( $filename = '', $username = '' ) {
|
890 |
global $cache_path, $wp_cache_debug_username, $wp_cache_debug_log;
|
891 |
if ( $filename != '' ) {
|
@@ -896,7 +906,7 @@ function wpsc_create_debug_log( $filename = '', $username = '' ) {
|
|
896 |
if ( $username != '' ) {
|
897 |
$wp_cache_debug_username = $username;
|
898 |
} else {
|
899 |
-
$wp_cache_debug_username =
|
900 |
}
|
901 |
|
902 |
$msg = '
|
@@ -1096,7 +1106,7 @@ function wp_cache_replace_line( $old, $new, $my_file ) {
|
|
1096 |
@rename( $tmp_file, $my_file );
|
1097 |
|
1098 |
if ( function_exists( "opcache_invalidate" ) ) {
|
1099 |
-
opcache_invalidate( $my_file );
|
1100 |
}
|
1101 |
|
1102 |
return true;
|
@@ -1106,7 +1116,7 @@ function wp_cache_phase2() {
|
|
1106 |
global $wp_cache_gzip_encoding, $super_cache_enabled, $cache_rebuild_files, $cache_enabled, $wp_cache_gmt_offset, $wp_cache_blog_charset;
|
1107 |
|
1108 |
if ( $cache_enabled == false ) {
|
1109 |
-
wp_cache_debug(
|
1110 |
return false;
|
1111 |
}
|
1112 |
|
@@ -1116,34 +1126,15 @@ function wp_cache_phase2() {
|
|
1116 |
$wp_cache_blog_charset = get_option( 'blog_charset' );
|
1117 |
|
1118 |
wp_cache_mutex_init();
|
1119 |
-
if(function_exists('add_action') && ( !defined( 'WPLOCKDOWN' ) ||
|
1120 |
wp_cache_debug( 'Setting up WordPress actions', 5 );
|
1121 |
|
1122 |
add_action( 'template_redirect', 'wp_super_cache_query_vars' );
|
1123 |
add_filter( 'wp_redirect_status', 'wpsc_catch_http_status_code' );
|
1124 |
add_filter( 'status_header', 'wpsc_catch_status_header', 10, 2 );
|
1125 |
-
|
1126 |
-
// Post ID is received
|
1127 |
-
add_action('wp_trash_post', 'wp_cache_post_edit', 0);
|
1128 |
-
add_action('publish_post', 'wp_cache_post_edit', 0);
|
1129 |
-
add_action('edit_post', 'wp_cache_post_change', 0); // leaving a comment called edit_post
|
1130 |
-
add_action('delete_post', 'wp_cache_post_edit', 0);
|
1131 |
-
add_action('publish_phone', 'wp_cache_post_edit', 0);
|
1132 |
-
// Coment ID is received
|
1133 |
-
add_action('trackback_post', 'wp_cache_get_postid_from_comment', 99);
|
1134 |
-
add_action('pingback_post', 'wp_cache_get_postid_from_comment', 99);
|
1135 |
-
add_action('comment_post', 'wp_cache_get_postid_from_comment', 99);
|
1136 |
-
add_action('edit_comment', 'wp_cache_get_postid_from_comment', 99);
|
1137 |
-
add_action('wp_set_comment_status', 'wp_cache_get_postid_from_comment', 99, 2);
|
1138 |
-
// No post_id is available
|
1139 |
-
add_action('switch_theme', 'wp_cache_no_postid', 99);
|
1140 |
-
add_action('edit_user_profile_update', 'wp_cache_no_postid', 99);
|
1141 |
-
add_action( 'wp_update_nav_menu', 'wp_cache_clear_cache_on_menu' );
|
1142 |
-
add_action('wp_cache_gc','wp_cache_gc_cron');
|
1143 |
-
add_action( 'clean_post_cache', 'wp_cache_post_edit' );
|
1144 |
add_filter( 'supercache_filename_str', 'wp_cache_check_mobile' );
|
1145 |
-
|
1146 |
-
|
1147 |
|
1148 |
do_cacheaction( 'add_cacheaction' );
|
1149 |
}
|
@@ -1158,24 +1149,67 @@ function wp_cache_phase2() {
|
|
1158 |
$super_cache_enabled = false;
|
1159 |
}
|
1160 |
|
1161 |
-
|
1162 |
-
|
1163 |
-
else
|
1164 |
-
header('Vary: Cookie');
|
1165 |
ob_start( 'wp_cache_ob_callback' );
|
1166 |
wp_cache_debug( 'Created output buffer', 4 );
|
1167 |
|
1168 |
// restore old supercache file temporarily
|
1169 |
-
if ( ( $_SERVER[
|
1170 |
$user_info = wp_cache_get_cookies_values();
|
1171 |
-
|
1172 |
-
if( $user_info
|
|
|
|
|
1173 |
wpcache_do_rebuild( get_current_url_supercache_dir() );
|
|
|
1174 |
}
|
1175 |
|
1176 |
schedule_wp_gc();
|
1177 |
}
|
1178 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1179 |
function wpcache_do_rebuild( $dir ) {
|
1180 |
global $do_rebuild_list, $cache_path, $wpsc_file_mtimes;
|
1181 |
wp_cache_debug( "wpcache_do_rebuild: doing rebuild for $dir" );
|
@@ -1187,7 +1221,7 @@ function wpcache_do_rebuild( $dir ) {
|
|
1187 |
|
1188 |
$dir = wpsc_get_realpath( $dir );
|
1189 |
if ( ! $dir ) {
|
1190 |
-
wp_cache_debug(
|
1191 |
return false;
|
1192 |
}
|
1193 |
|
@@ -1415,15 +1449,15 @@ function wp_cache_writers_entry() {
|
|
1415 |
return true;
|
1416 |
|
1417 |
if( !$mutex ) {
|
1418 |
-
wp_cache_debug(
|
1419 |
return false;
|
1420 |
}
|
1421 |
|
1422 |
if ( $use_flock ) {
|
1423 |
-
wp_cache_debug(
|
1424 |
flock($mutex, LOCK_EX);
|
1425 |
} else {
|
1426 |
-
wp_cache_debug(
|
1427 |
@sem_acquire($mutex);
|
1428 |
}
|
1429 |
|
@@ -1437,15 +1471,15 @@ function wp_cache_writers_exit() {
|
|
1437 |
return true;
|
1438 |
|
1439 |
if( !$mutex ) {
|
1440 |
-
wp_cache_debug(
|
1441 |
return false;
|
1442 |
}
|
1443 |
|
1444 |
if ( $use_flock ) {
|
1445 |
-
wp_cache_debug(
|
1446 |
flock( $mutex, LOCK_UN );
|
1447 |
} else {
|
1448 |
-
wp_cache_debug(
|
1449 |
@sem_release( $mutex );
|
1450 |
if ( defined( "WPSC_REMOVE_SEMAPHORE" ) )
|
1451 |
@sem_remove( $mutex );
|
@@ -1561,7 +1595,7 @@ function wp_cache_ob_callback( $buffer ) {
|
|
1561 |
wp_cache_debug( 'DONOTCACHEPAGE defined. Caching disabled.', 2 );
|
1562 |
$cache_this_page = false;
|
1563 |
} elseif ( $wp_cache_no_cache_for_get && ! empty( $_GET ) ) {
|
1564 |
-
wp_cache_debug(
|
1565 |
$cache_this_page = false;
|
1566 |
} elseif ( $_SERVER["REQUEST_METHOD"] == 'POST' || !empty( $_POST ) || get_option( 'gzipcompression' ) ) {
|
1567 |
wp_cache_debug( 'Not caching POST request.', 5 );
|
@@ -1751,7 +1785,7 @@ function wp_cache_get_ob(&$buffer) {
|
|
1751 |
if ( isset( $wp_super_cache_query[ 'is_404' ] ) && false == apply_filters( 'wpsupercache_404', false ) ) {
|
1752 |
$new_cache = false;
|
1753 |
if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) {
|
1754 |
-
wp_cache_debug(
|
1755 |
wp_cache_add_to_buffer( $buffer, "Page not cached by WP Super Cache. 404." );
|
1756 |
}
|
1757 |
}
|
@@ -1759,7 +1793,7 @@ function wp_cache_get_ob(&$buffer) {
|
|
1759 |
if ( !preg_match( apply_filters( 'wp_cache_eof_tags', '/(<\/html>|<\/rss>|<\/feed>|<\/urlset|<\?xml)/i' ), $buffer ) ) {
|
1760 |
$new_cache = false;
|
1761 |
if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) {
|
1762 |
-
wp_cache_debug(
|
1763 |
wp_cache_add_to_buffer( $buffer, "Page not cached by WP Super Cache. No closing HTML tag. Check your theme." );
|
1764 |
}
|
1765 |
}
|
@@ -1773,12 +1807,12 @@ function wp_cache_get_ob(&$buffer) {
|
|
1773 |
|
1774 |
if( !wp_cache_writers_entry() ) {
|
1775 |
wp_cache_add_to_buffer( $buffer, "Page not cached by WP Super Cache. Could not get mutex lock." );
|
1776 |
-
wp_cache_debug(
|
1777 |
return wp_cache_maybe_dynamic( $buffer );
|
1778 |
}
|
1779 |
|
1780 |
if ( $wp_cache_not_logged_in && isset( $wp_super_cache_query[ 'is_feed' ] ) ) {
|
1781 |
-
wp_cache_debug(
|
1782 |
$wp_cache_not_logged_in = false;
|
1783 |
}
|
1784 |
|
@@ -1787,7 +1821,7 @@ function wp_cache_get_ob(&$buffer) {
|
|
1787 |
$dir = get_current_url_supercache_dir();
|
1788 |
$supercachedir = $cache_path . 'supercache/' . preg_replace('/:.*$/', '', $home_url[ 'host' ]);
|
1789 |
if ( ! empty( $_GET ) || isset( $wp_super_cache_query[ 'is_feed' ] ) || ( $super_cache_enabled == true && is_dir( substr( $supercachedir, 0, -1 ) . '.disabled' ) ) ) {
|
1790 |
-
wp_cache_debug(
|
1791 |
$super_cache_enabled = false;
|
1792 |
}
|
1793 |
|
@@ -1796,7 +1830,7 @@ function wp_cache_get_ob(&$buffer) {
|
|
1796 |
$supercacheonly = false;
|
1797 |
if( $super_cache_enabled ) {
|
1798 |
if ( wp_cache_get_cookies_values() == '' && empty( $_GET ) ) {
|
1799 |
-
wp_cache_debug(
|
1800 |
$supercacheonly = true;
|
1801 |
}
|
1802 |
}
|
@@ -1837,7 +1871,7 @@ function wp_cache_get_ob(&$buffer) {
|
|
1837 |
$dir = wpsc_get_realpath( $dir );
|
1838 |
|
1839 |
if ( ! $dir ) {
|
1840 |
-
wp_cache_debug(
|
1841 |
return $buffer;
|
1842 |
}
|
1843 |
|
@@ -1854,7 +1888,7 @@ function wp_cache_get_ob(&$buffer) {
|
|
1854 |
if ( !$supercacheonly ) {
|
1855 |
$fr = @fopen($tmp_wpcache_filename, 'w');
|
1856 |
if (!$fr) {
|
1857 |
-
wp_cache_debug(
|
1858 |
wp_cache_add_to_buffer( $buffer, "File not cached! Super Cache Couldn't write to: " . str_replace( ABSPATH, '', $cache_path ) . $cache_filename );
|
1859 |
wp_cache_writers_exit();
|
1860 |
return wp_cache_maybe_dynamic( $buffer );
|
@@ -1868,7 +1902,7 @@ function wp_cache_get_ob(&$buffer) {
|
|
1868 |
$tmp_cache_filename = $dir . uniqid( mt_rand(), true ) . '.tmp';
|
1869 |
$fr2 = @fopen( $tmp_cache_filename, 'w' );
|
1870 |
if ( !$fr2 ) {
|
1871 |
-
wp_cache_debug(
|
1872 |
wp_cache_add_to_buffer( $buffer, "File not cached! Super Cache Couldn't write to: " . str_replace( ABSPATH, '', $tmp_cache_filename ) );
|
1873 |
@fclose( $fr );
|
1874 |
@unlink( $tmp_wpcache_filename );
|
@@ -1877,7 +1911,7 @@ function wp_cache_get_ob(&$buffer) {
|
|
1877 |
} elseif ( ( !isset( $wp_cache_mfunc_enabled ) || $wp_cache_mfunc_enabled == 0 ) && $cache_compression ) { // don't want to store compressed files if using dynamic content
|
1878 |
$gz = @fopen( $tmp_cache_filename . ".gz", 'w');
|
1879 |
if (!$gz) {
|
1880 |
-
wp_cache_debug(
|
1881 |
wp_cache_add_to_buffer( $buffer, "File not cached! Super Cache Couldn't write to: " . str_replace( ABSPATH, '', $tmp_cache_filename ) . ".gz" );
|
1882 |
@fclose( $fr );
|
1883 |
@unlink( $tmp_wpcache_filename );
|
@@ -1902,7 +1936,7 @@ function wp_cache_get_ob(&$buffer) {
|
|
1902 |
*/
|
1903 |
if ( $wp_cache_mfunc_enabled == 1 ) {
|
1904 |
if ( preg_match( '/<!--mclude|<!--mfunc|<!--dynamic-cached-content-->/', $buffer ) ) { //Dynamic content
|
1905 |
-
wp_cache_debug(
|
1906 |
wp_cache_add_to_buffer( $buffer, "Warning! Obsolete mfunc/mclude/dynamic-cached-content tags found. Please update your theme. See http://ocaoimh.ie/y/5b for more information." );
|
1907 |
}
|
1908 |
|
@@ -1911,11 +1945,11 @@ function wp_cache_get_ob(&$buffer) {
|
|
1911 |
wp_cache_add_to_buffer( $buffer, 'Super Cache dynamic page detected but late init not set. See the readme.txt for further details.' );
|
1912 |
|
1913 |
if ( $fr ) { // wpcache caching
|
1914 |
-
wp_cache_debug(
|
1915 |
wp_cache_add_to_buffer( $buffer, "Dynamic WPCache Super Cache" );
|
1916 |
fputs( $fr, '<?php die(); ?>' . $buffer );
|
1917 |
} elseif ( isset( $fr2 ) ) { // supercache active
|
1918 |
-
wp_cache_debug(
|
1919 |
wp_cache_add_to_buffer( $buffer, "Dynamic Super Cache" );
|
1920 |
fputs( $fr2, $buffer );
|
1921 |
} elseif ( true == $wp_cache_object_cache ) {
|
@@ -1927,14 +1961,14 @@ function wp_cache_get_ob(&$buffer) {
|
|
1927 |
}
|
1928 |
|
1929 |
if ( $cache_compression && $wp_cache_gzip_encoding ) {
|
1930 |
-
wp_cache_debug(
|
1931 |
wp_cache_add_to_buffer( $buffer, "Compression = gzip" );
|
1932 |
$gzdata = gzencode( $buffer, 6, FORCE_GZIP );
|
1933 |
$gzsize = function_exists( 'mb_strlen' ) ? mb_strlen( $gzdata, '8bit' ) : strlen( $gzdata );
|
1934 |
}
|
1935 |
} else {
|
1936 |
if ( $gz || $wp_cache_gzip_encoding ) {
|
1937 |
-
wp_cache_debug(
|
1938 |
wp_cache_add_to_buffer( $buffer, "Compression = gzip" );
|
1939 |
$gzdata = gzencode( $buffer, 6, FORCE_GZIP );
|
1940 |
$gzsize = function_exists( 'mb_strlen' ) ? mb_strlen( $gzdata, '8bit' ) : strlen( $gzdata );
|
@@ -1943,7 +1977,7 @@ function wp_cache_get_ob(&$buffer) {
|
|
1943 |
$wp_cache_meta[ 'headers' ][ 'Vary' ] = 'Vary: Accept-Encoding, Cookie';
|
1944 |
// Return uncompressed data & store compressed for later use
|
1945 |
if ( $fr ) {
|
1946 |
-
wp_cache_debug(
|
1947 |
fputs($fr, '<?php die(); ?>' . $gzdata);
|
1948 |
} elseif ( $cache_enabled && $wp_cache_object_cache ) {
|
1949 |
wp_cache_set( $oc_key . ".gz", $gzdata, 'supercache', $cache_max_time );
|
@@ -1955,17 +1989,17 @@ function wp_cache_get_ob(&$buffer) {
|
|
1955 |
wp_cache_set( $oc_key, $buffer, 'supercache', $cache_max_time );
|
1956 |
$added_cache = 1;
|
1957 |
} elseif ( $fr ) {
|
1958 |
-
wp_cache_debug(
|
1959 |
fputs($fr, '<?php die(); ?>' . $buffer);
|
1960 |
}
|
1961 |
}
|
1962 |
if ( $fr2 ) {
|
1963 |
-
wp_cache_debug(
|
1964 |
wp_cache_add_to_buffer( $buffer, "super cache" );
|
1965 |
fputs($fr2, $buffer );
|
1966 |
}
|
1967 |
if ( isset( $gzdata ) && $gz ) {
|
1968 |
-
wp_cache_debug(
|
1969 |
fwrite($gz, $gzdata );
|
1970 |
}
|
1971 |
}
|
@@ -1976,16 +2010,20 @@ function wp_cache_get_ob(&$buffer) {
|
|
1976 |
$supercacheonly = false;
|
1977 |
fclose($fr);
|
1978 |
if ( filesize( $tmp_wpcache_filename ) == 0 ) {
|
1979 |
-
wp_cache_debug( "Warning! The file $tmp_wpcache_filename was empty. Did not rename to {$dir}
|
1980 |
@unlink( $tmp_wpcache_filename );
|
1981 |
} else {
|
1982 |
-
if ( !@rename( $tmp_wpcache_filename, $dir .
|
1983 |
if ( false == is_dir( $dir ) )
|
1984 |
@wp_mkdir_p( $dir );
|
1985 |
@unlink( $dir . $cache_filename );
|
1986 |
-
@rename( $tmp_wpcache_filename, $dir .
|
|
|
|
|
|
|
|
|
|
|
1987 |
}
|
1988 |
-
wp_cache_debug( "Renamed temp wp-cache file to {$dir}/$cache_filename", 5 );
|
1989 |
$added_cache = 1;
|
1990 |
}
|
1991 |
}
|
@@ -1993,7 +2031,7 @@ function wp_cache_get_ob(&$buffer) {
|
|
1993 |
fclose($fr2);
|
1994 |
if ( $wp_cache_front_page_checks && $cache_fname == $supercachedir . $home_url[ 'path' ] . supercache_filename() && !( $wp_cache_is_home ) ) {
|
1995 |
wp_cache_writers_exit();
|
1996 |
-
wp_cache_debug(
|
1997 |
return $buffer;
|
1998 |
} elseif ( filesize( $tmp_cache_filename ) == 0 ) {
|
1999 |
wp_cache_debug( "Warning! The file $tmp_cache_filename was empty. Did not rename to {$cache_fname}", 5 );
|
@@ -2032,13 +2070,13 @@ function wp_cache_get_ob(&$buffer) {
|
|
2032 |
}
|
2033 |
wp_cache_writers_exit();
|
2034 |
if ( !headers_sent() && $wp_cache_gzip_encoding && $gzdata) {
|
2035 |
-
wp_cache_debug(
|
2036 |
header( 'Content-Encoding: ' . $wp_cache_gzip_encoding );
|
2037 |
header( 'Vary: Accept-Encoding, Cookie' );
|
2038 |
header( 'Content-Length: ' . $gzsize );
|
2039 |
return $gzdata;
|
2040 |
} else {
|
2041 |
-
wp_cache_debug(
|
2042 |
return $buffer;
|
2043 |
}
|
2044 |
}
|
@@ -2067,6 +2105,7 @@ function wp_cache_phase2_clean_cache($file_prefix) {
|
|
2067 |
}
|
2068 |
}
|
2069 |
closedir($handle);
|
|
|
2070 |
}
|
2071 |
wp_cache_writers_exit();
|
2072 |
}
|
@@ -2075,7 +2114,7 @@ function prune_super_cache( $directory, $force = false, $rename = false ) {
|
|
2075 |
|
2076 |
// Don't prune a NULL/empty directory.
|
2077 |
if ( null === $directory || '' === $directory ) {
|
2078 |
-
wp_cache_debug(
|
2079 |
return false;
|
2080 |
}
|
2081 |
|
@@ -2280,12 +2319,12 @@ function wp_cache_shutdown_callback() {
|
|
2280 |
* ref: https://wordpress.org/support/topic/fatal-error-while-updating-post-or-publishing-new-one/
|
2281 |
*/
|
2282 |
$wpsc_feed_ttl = 1;
|
2283 |
-
wp_cache_debug(
|
2284 |
}
|
2285 |
|
2286 |
|
2287 |
if ( false == $new_cache ) {
|
2288 |
-
wp_cache_debug(
|
2289 |
return false;
|
2290 |
}
|
2291 |
|
@@ -2300,7 +2339,7 @@ function wp_cache_shutdown_callback() {
|
|
2300 |
$wp_cache_meta[ 'headers' ][ $key ] = "$key: $value";
|
2301 |
}
|
2302 |
|
2303 |
-
wp_cache_debug(
|
2304 |
|
2305 |
if (!isset( $response['Last-Modified'] )) {
|
2306 |
$value = gmdate('D, d M Y H:i:s') . ' GMT';
|
@@ -2358,7 +2397,7 @@ function wp_cache_shutdown_callback() {
|
|
2358 |
|
2359 |
if ( $cache_enabled && !$supercacheonly && $new_cache ) {
|
2360 |
if( !isset( $wp_cache_meta[ 'dynamic' ] ) && $wp_cache_gzip_encoding && !in_array( 'Content-Encoding: ' . $wp_cache_gzip_encoding, $wp_cache_meta[ 'headers' ] ) ) {
|
2361 |
-
wp_cache_debug(
|
2362 |
$wp_cache_meta[ 'headers' ][ 'Content-Encoding' ] = 'Content-Encoding: ' . $wp_cache_gzip_encoding;
|
2363 |
$wp_cache_meta[ 'headers' ][ 'Vary' ] = 'Vary: Accept-Encoding, Cookie';
|
2364 |
}
|
@@ -2408,7 +2447,7 @@ function wp_cache_shutdown_callback() {
|
|
2408 |
}
|
2409 |
global $time_to_gc_cache;
|
2410 |
if( isset( $time_to_gc_cache ) && $time_to_gc_cache == 1 ) {
|
2411 |
-
wp_cache_debug(
|
2412 |
do_action( 'wp_cache_gc' );
|
2413 |
}
|
2414 |
}
|
@@ -2463,7 +2502,7 @@ function wp_cache_get_postid_from_comment( $comment_id, $status = 'NA' ) {
|
|
2463 |
$super_cache_enabled = 0; // don't remove the super cache static file until comment is approved
|
2464 |
define( 'DONOTDELETECACHE', 1 );
|
2465 |
} else {
|
2466 |
-
wp_cache_debug(
|
2467 |
define( 'DONOTDELETECACHE', 1 );
|
2468 |
return $postid;
|
2469 |
}
|
@@ -2476,7 +2515,7 @@ function wp_cache_get_postid_from_comment( $comment_id, $status = 'NA' ) {
|
|
2476 |
wp_cache_debug( "Post $postid changed. Update cache.", 4 );
|
2477 |
return wp_cache_post_change( $postid );
|
2478 |
} else {
|
2479 |
-
wp_cache_debug(
|
2480 |
return wp_cache_post_change( wp_cache_post_id() );
|
2481 |
}
|
2482 |
}
|
@@ -2494,7 +2533,7 @@ function wp_cache_clear_cache( $blog_id = 0 ) {
|
|
2494 |
reset_oc_version();
|
2495 |
} else {
|
2496 |
if ( $blog_id == 0 ) {
|
2497 |
-
wp_cache_debug(
|
2498 |
prune_super_cache( $cache_path . 'supercache/', true );
|
2499 |
prune_super_cache( $cache_path, true );
|
2500 |
} else {
|
@@ -2503,6 +2542,7 @@ function wp_cache_clear_cache( $blog_id = 0 ) {
|
|
2503 |
prune_super_cache( $cache_path . 'blogs/', true );
|
2504 |
}
|
2505 |
}
|
|
|
2506 |
}
|
2507 |
|
2508 |
function wpsc_delete_post_archives( $post ) {
|
@@ -2531,7 +2571,7 @@ function wpsc_delete_post_archives( $post ) {
|
|
2531 |
}
|
2532 |
|
2533 |
wpsc_delete_url_cache( $term_url );
|
2534 |
-
wp_cache_debug(
|
2535 |
}
|
2536 |
}
|
2537 |
|
@@ -2546,14 +2586,14 @@ function wpsc_delete_post_archives( $post ) {
|
|
2546 |
|
2547 |
if ( $archive_url ) {
|
2548 |
wpsc_delete_url_cache( $archive_url );
|
2549 |
-
wp_cache_debug(
|
2550 |
}
|
2551 |
|
2552 |
// Author archive page
|
2553 |
$author_url = get_author_posts_url( $post->post_author );
|
2554 |
if ( $author_url ) {
|
2555 |
wpsc_delete_url_cache( $author_url );
|
2556 |
-
wp_cache_debug(
|
2557 |
}
|
2558 |
}
|
2559 |
|
@@ -2567,7 +2607,7 @@ function wpsc_delete_cats_tags( $post ) {
|
|
2567 |
$category_base = trailingslashit( $category_base ); // paranoid much?
|
2568 |
foreach ($categories as $cat) {
|
2569 |
prune_super_cache ( get_supercache_dir() . $category_base . $cat->slug . '/', true );
|
2570 |
-
wp_cache_debug(
|
2571 |
}
|
2572 |
}
|
2573 |
$posttags = get_the_tags($post->ID);
|
@@ -2578,7 +2618,7 @@ function wpsc_delete_cats_tags( $post ) {
|
|
2578 |
$tag_base = trailingslashit( str_replace( '..', '', $tag_base ) ); // maybe!
|
2579 |
foreach ($posttags as $tag) {
|
2580 |
prune_super_cache( get_supercache_dir() . $tag_base . $tag->slug . '/', true );
|
2581 |
-
wp_cache_debug(
|
2582 |
}
|
2583 |
}
|
2584 |
}
|
@@ -2587,13 +2627,13 @@ function wpsc_post_transition( $new_status, $old_status, $post ) {
|
|
2587 |
if (
|
2588 |
($old_status == 'publish' && $new_status != 'publish' ) // post unpublished
|
2589 |
||
|
2590 |
-
($
|
2591 |
) {
|
2592 |
//wpsc_delete_cats_tags( $post );
|
2593 |
wpsc_delete_post_archives( $post );
|
2594 |
$post_url = get_permalink( $post->ID );
|
2595 |
wpsc_delete_url_cache( $post_url );
|
2596 |
-
wp_cache_debug(
|
2597 |
}
|
2598 |
}
|
2599 |
|
@@ -2614,7 +2654,7 @@ function wp_cache_post_edit($post_id) {
|
|
2614 |
// Some users are inexplicibly seeing this error on scheduled posts.
|
2615 |
// define this constant to disable the post status check.
|
2616 |
if ( false == defined( 'WPSCFORCEUPDATE' ) && !in_array($post->post_status, array( 'publish', 'private' ) ) ) {
|
2617 |
-
wp_cache_debug(
|
2618 |
return $post_id;
|
2619 |
}
|
2620 |
|
@@ -2679,7 +2719,7 @@ function wp_cache_post_change( $post_id ) {
|
|
2679 |
// Some users are inexplicibly seeing this error on scheduled posts.
|
2680 |
// define this constant to disable the post status check.
|
2681 |
if ( false == defined( 'WPSCFORCEUPDATE' ) && is_object( $post ) && !in_array($post->post_status, array( 'publish', 'private' ) ) ) {
|
2682 |
-
wp_cache_debug(
|
2683 |
return $post_id;
|
2684 |
}
|
2685 |
$last_processed = $post_id;
|
@@ -2687,12 +2727,20 @@ function wp_cache_post_change( $post_id ) {
|
|
2687 |
if( !wp_cache_writers_entry() )
|
2688 |
return $post_id;
|
2689 |
|
2690 |
-
if (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2691 |
if ( defined( 'DONOTDELETECACHE' ) ) {
|
2692 |
wp_cache_debug( "wp_cache_post_change: comment detected and it's moderated or spam. Not deleting cached files.", 4 );
|
2693 |
return $post_id;
|
2694 |
} else {
|
2695 |
-
wp_cache_debug(
|
2696 |
$all = false;
|
2697 |
}
|
2698 |
} else {
|
@@ -2711,24 +2759,24 @@ function wp_cache_post_change( $post_id ) {
|
|
2711 |
$dir = get_supercache_dir();
|
2712 |
// make sure the front page has a rebuild file
|
2713 |
if ( false == wp_cache_post_id_gc( $post_id, $all ) ) {
|
2714 |
-
wp_cache_debug(
|
2715 |
wp_cache_writers_exit();
|
2716 |
return false;
|
2717 |
}
|
2718 |
if ( $all == true ) {
|
2719 |
-
wp_cache_debug(
|
2720 |
wpsc_rebuild_files( $dir );
|
2721 |
do_action( 'gc_cache', 'prune', 'homepage' );
|
2722 |
if ( get_option( 'show_on_front' ) == 'page' ) {
|
2723 |
-
wp_cache_debug(
|
2724 |
-
wp_cache_debug(
|
2725 |
$permalink = trailingslashit( str_replace( get_option( 'home' ), '', get_permalink( get_option( 'page_for_posts' ) ) ) );
|
2726 |
-
wp_cache_debug(
|
2727 |
wpsc_rebuild_files( $dir . $permalink );
|
2728 |
do_action( 'gc_cache', 'prune', $permalink );
|
2729 |
}
|
2730 |
} else {
|
2731 |
-
wp_cache_debug(
|
2732 |
}
|
2733 |
|
2734 |
wp_cache_debug( "wp_cache_post_change: checking {$blog_cache_dir}meta/", 4 );
|
53 |
}
|
54 |
|
55 |
if ( wp_cache_user_agent_is_rejected() ) {
|
56 |
+
wp_cache_debug( 'No wp-cache file served as user agent rejected.', 5 );
|
57 |
return false;
|
58 |
}
|
59 |
|
60 |
if ( $wp_cache_no_cache_for_get && false == empty( $_GET ) ) {
|
61 |
+
wp_cache_debug( 'Non empty GET request. Caching disabled on settings page. ' . wpsc_dump_get_request(), 1 );
|
62 |
return false;
|
63 |
}
|
64 |
|
66 |
|
67 |
if ( $wp_cache_object_cache && wp_cache_get_cookies_values() == '' ) {
|
68 |
if ( !empty( $_GET ) ) {
|
69 |
+
wp_cache_debug( 'Non empty GET request. Not serving request from object cache. ' . wpsc_dump_get_request(), 1 );
|
70 |
return false;
|
71 |
}
|
72 |
|
79 |
$cache = wp_cache_get( $oc_key, 'supercache' );
|
80 |
$meta = json_decode( wp_cache_get( $meta_filename, 'supercache' ), true );
|
81 |
if ( is_array( $meta ) == false ) {
|
82 |
+
wp_cache_debug( 'Meta array from object cache corrupt. Ignoring cache.', 1 );
|
83 |
return true;
|
84 |
}
|
85 |
} elseif ( ( $cache_file && file_exists( $cache_file ) ) || file_exists( get_current_url_supercache_dir() . 'meta-' . $cache_filename ) ) {
|
87 |
$cache_file = get_current_url_supercache_dir() . $cache_filename;
|
88 |
$meta_pathname = get_current_url_supercache_dir() . 'meta-' . $cache_filename;
|
89 |
} elseif ( !file_exists( $cache_file ) ) {
|
90 |
+
wp_cache_debug( 'wp_cache_serve_cache_file: found cache file but then it disappeared!' );
|
91 |
return false;
|
92 |
}
|
93 |
|
111 |
wp_cache_debug( "No Super Cache file found for current URL: $file" );
|
112 |
return false;
|
113 |
} elseif ( false == empty( $_GET ) ) {
|
114 |
+
wp_cache_debug( 'GET array not empty. Cannot serve a supercache file. ' . wpsc_dump_get_request() );
|
115 |
return false;
|
116 |
} elseif ( wp_cache_get_cookies_values() != '' ) {
|
117 |
+
wp_cache_debug( 'Cookies found. Cannot serve a supercache file. ' . wp_cache_get_cookies_values() );
|
118 |
return false;
|
119 |
} elseif ( isset( $wpsc_save_headers ) && $wpsc_save_headers ) {
|
120 |
+
wp_cache_debug( 'Saving headers. Cannot serve a supercache file.' );
|
121 |
return false;
|
122 |
}
|
123 |
|
199 |
echo $cachefiledata;
|
200 |
exit();
|
201 |
} else {
|
202 |
+
wp_cache_debug( 'No wp-cache file exists. Must generate a new one.' );
|
203 |
return false;
|
204 |
}
|
205 |
}
|
208 |
// Sometimes the gzip headers are lost. Make sure html returned isn't compressed!
|
209 |
if ( $cache_compression && $wp_cache_gzip_encoding && !in_array( 'Content-Encoding: ' . $wp_cache_gzip_encoding, $meta[ 'headers' ] ) ) {
|
210 |
$ungzip = true;
|
211 |
+
wp_cache_debug( 'GZIP headers not found. Force uncompressed output.', 1 );
|
212 |
} else {
|
213 |
$ungzip = false;
|
214 |
}
|
226 |
// attempt to uncompress the cached file just in case it's gzipped
|
227 |
$uncompressed = gzuncompress( $cache );
|
228 |
if ( $uncompressed ) {
|
229 |
+
wp_cache_debug( 'Uncompressed gzipped cache file from object cache', 1 );
|
230 |
$cache = $uncompressed;
|
231 |
unset( $uncompressed );
|
232 |
}
|
233 |
}
|
234 |
if ( isset( $meta[ 'dynamic' ] ) && $meta[ 'dynamic' ] ) {
|
235 |
+
wp_cache_debug( 'Serving wp-cache dynamic file from object cache', 5 );
|
236 |
echo do_cacheaction( 'wpsc_cachedata', $cache );
|
237 |
} else {
|
238 |
+
wp_cache_debug( 'Serving wp-cache static file from object cache', 5 );
|
239 |
echo $cache;
|
240 |
}
|
241 |
+
wp_cache_debug( 'exit request', 5 );
|
242 |
die();
|
243 |
}
|
244 |
} else {
|
245 |
if ( isset( $meta[ 'dynamic' ] ) ) {
|
246 |
+
wp_cache_debug( 'Serving wp-cache dynamic file', 5 );
|
247 |
if ( $ungzip ) {
|
248 |
// attempt to uncompress the cached file just in case it's gzipped
|
249 |
$cache = wp_cache_get_legacy_cache( $cache_file );
|
250 |
$uncompressed = @gzuncompress( $cache );
|
251 |
if ( $uncompressed ) {
|
252 |
+
wp_cache_debug( 'Uncompressed gzipped cache file from wp-cache', 1 );
|
253 |
unset( $cache );
|
254 |
echo do_cacheaction( 'wpsc_cachedata', $uncompressed );
|
255 |
} else {
|
259 |
echo do_cacheaction( 'wpsc_cachedata', wp_cache_get_legacy_cache( $cache_file ) );
|
260 |
}
|
261 |
} else {
|
262 |
+
wp_cache_debug( 'Serving wp-cache static file', 5 );
|
263 |
if ( $ungzip ) {
|
264 |
$cache = wp_cache_get_legacy_cache( $cache_file );
|
265 |
$uncompressed = gzuncompress( $cache );
|
266 |
if ( $uncompressed ) {
|
267 |
+
wp_cache_debug( 'Uncompressed gzipped cache file from wp-cache', 1 );
|
268 |
echo $uncompressed;
|
269 |
} else {
|
270 |
+
wp_cache_debug( 'Compressed gzipped cache file from wp-cache', 1 );
|
271 |
echo $cache;
|
272 |
}
|
273 |
} else {
|
274 |
+
wp_cache_debug( 'Getting legacy cache file ' . $cache_file, 1 );
|
275 |
echo( wp_cache_get_legacy_cache( $cache_file ) );
|
276 |
}
|
277 |
}
|
278 |
+
wp_cache_debug( 'exit request', 5 );
|
279 |
die();
|
280 |
}
|
281 |
}
|
291 |
return true;
|
292 |
|
293 |
if ( isset( $wp_super_cache_late_init ) && true == $wp_super_cache_late_init ) {
|
294 |
+
wp_cache_debug( 'Supercache Late Init: add wp_cache_serve_cache_file to init', 3 );
|
295 |
add_action( 'init', 'wp_cache_late_loader', 9999 );
|
296 |
} else {
|
297 |
wp_super_cache_init();
|
300 |
}
|
301 |
|
302 |
function wp_cache_late_loader() {
|
303 |
+
wp_cache_debug( 'Supercache Late Loader running on init', 3 );
|
304 |
wp_cache_serve_cache_file();
|
305 |
wp_cache_phase2();
|
306 |
}
|
386 |
// allow plugins to short circuit mobile check. Cookie, extra UA checks?
|
387 |
switch( do_cacheaction( 'wp_cache_check_mobile', $cache_key ) ) {
|
388 |
case "normal":
|
389 |
+
wp_cache_debug( 'wp_cache_check_mobile: desktop user agent detected by wp_cache_check_mobile action' );
|
390 |
return $cache_key;
|
391 |
break;
|
392 |
case "mobile":
|
393 |
+
wp_cache_debug( 'wp_cache_check_mobile: mobile user agent detected by wp_cache_check_mobile action' );
|
394 |
return $cache_key . "-mobile";
|
395 |
break;
|
396 |
}
|
400 |
}
|
401 |
|
402 |
if ( do_cacheaction( 'disable_mobile_check', false ) ) {
|
403 |
+
wp_cache_debug( 'wp_cache_check_mobile: disable_mobile_check disabled mobile check' );
|
404 |
return $cache_key;
|
405 |
}
|
406 |
|
408 |
$user_agent = strtolower( $_SERVER['HTTP_USER_AGENT'] );
|
409 |
foreach ($browsers as $browser) {
|
410 |
if ( strstr( $user_agent, trim( strtolower( $browser ) ) ) ) {
|
411 |
+
wp_cache_debug( 'mobile browser detected: ' . $_SERVER['HTTP_USER_AGENT'], 5 );
|
412 |
return $cache_key . '-' . wp_cache_mobile_group( $user_agent );
|
413 |
}
|
414 |
}
|
421 |
$browsers = explode( ',', $wp_cache_mobile_prefixes );
|
422 |
foreach ($browsers as $browser_prefix) {
|
423 |
if ( substr($user_agent, 0, 4) == $browser_prefix ) {
|
424 |
+
wp_cache_debug( 'mobile browser (prefix) detected: ' . $_SERVER['HTTP_USER_AGENT'], 5 );
|
425 |
return $cache_key . '-' . $browser_prefix;
|
426 |
}
|
427 |
}
|
633 |
static $rp_cache_path = '';
|
634 |
|
635 |
if ( $directory == '' ) {
|
636 |
+
wp_cache_debug( 'wpsc_is_in_cache_directory: exiting as directory is blank' );
|
637 |
return false;
|
638 |
}
|
639 |
|
640 |
if ( $cache_path == '' ) {
|
641 |
+
wp_cache_debug( 'wpsc_is_in_cache_directory: exiting as cache_path is blank' );
|
642 |
return false;
|
643 |
}
|
644 |
|
647 |
}
|
648 |
|
649 |
if ( ! $rp_cache_path ) {
|
650 |
+
wp_cache_debug( 'wpsc_is_in_cache_directory: exiting as cache_path directory does not exist' );
|
651 |
return false;
|
652 |
}
|
653 |
|
654 |
$directory = wpsc_get_realpath( $directory );
|
655 |
|
656 |
if ( ! $directory ) {
|
657 |
+
wp_cache_debug( 'wpsc_is_in_cache_directory: directory does not exist' );
|
658 |
return false;
|
659 |
}
|
660 |
|
670 |
static $protected = '';
|
671 |
|
672 |
if ( $dir == '' ) {
|
673 |
+
wp_cache_debug( 'wpsc_delete_files: directory is blank' );
|
674 |
return false;
|
675 |
}
|
676 |
|
684 |
|
685 |
$dir = wpsc_get_realpath( $dir );
|
686 |
if ( ! $dir ) {
|
687 |
+
wp_cache_debug( 'wpsc_delete_files: directory does not exist: ' . $dir );
|
688 |
return false;
|
689 |
}
|
690 |
|
718 |
|
719 |
$dir = wpsc_get_realpath( $dir );
|
720 |
if ( ! $dir ) {
|
721 |
+
wp_cache_debug( 'get_all_supercache_filenames: directory does not exist' );
|
722 |
return array();
|
723 |
}
|
724 |
|
834 |
$dir = wpsc_get_realpath( $dir );
|
835 |
|
836 |
if ( ! $dir ) {
|
837 |
+
wp_cache_debug( 'wp_cache_confirm_delete: directory does not exist' );
|
838 |
return false;
|
839 |
}
|
840 |
|
888 |
);
|
889 |
}
|
890 |
|
891 |
+
function wpsc_debug_username() {
|
892 |
+
global $wp_cache_debug_username;
|
893 |
+
if ( ! isset( $wp_cache_debug_username ) || $wp_cache_debug_username == '' ) {
|
894 |
+
$wp_cache_debug_username = md5( time() + mt_rand() );
|
895 |
+
wp_cache_setting( 'wp_cache_debug_username', $wp_cache_debug_username );
|
896 |
+
}
|
897 |
+
return $wp_cache_debug_username;
|
898 |
+
}
|
899 |
function wpsc_create_debug_log( $filename = '', $username = '' ) {
|
900 |
global $cache_path, $wp_cache_debug_username, $wp_cache_debug_log;
|
901 |
if ( $filename != '' ) {
|
906 |
if ( $username != '' ) {
|
907 |
$wp_cache_debug_username = $username;
|
908 |
} else {
|
909 |
+
$wp_cache_debug_username = wpsc_debug_username();
|
910 |
}
|
911 |
|
912 |
$msg = '
|
1106 |
@rename( $tmp_file, $my_file );
|
1107 |
|
1108 |
if ( function_exists( "opcache_invalidate" ) ) {
|
1109 |
+
@opcache_invalidate( $my_file );
|
1110 |
}
|
1111 |
|
1112 |
return true;
|
1116 |
global $wp_cache_gzip_encoding, $super_cache_enabled, $cache_rebuild_files, $cache_enabled, $wp_cache_gmt_offset, $wp_cache_blog_charset;
|
1117 |
|
1118 |
if ( $cache_enabled == false ) {
|
1119 |
+
wp_cache_debug( 'Caching disabled! quiting!', 1 );
|
1120 |
return false;
|
1121 |
}
|
1122 |
|
1126 |
$wp_cache_blog_charset = get_option( 'blog_charset' );
|
1127 |
|
1128 |
wp_cache_mutex_init();
|
1129 |
+
if ( function_exists( 'add_action' ) && ( ! defined( 'WPLOCKDOWN' ) || constant( 'WPLOCKDOWN' ) == '0' ) ) {
|
1130 |
wp_cache_debug( 'Setting up WordPress actions', 5 );
|
1131 |
|
1132 |
add_action( 'template_redirect', 'wp_super_cache_query_vars' );
|
1133 |
add_filter( 'wp_redirect_status', 'wpsc_catch_http_status_code' );
|
1134 |
add_filter( 'status_header', 'wpsc_catch_status_header', 10, 2 );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1135 |
add_filter( 'supercache_filename_str', 'wp_cache_check_mobile' );
|
1136 |
+
|
1137 |
+
wpsc_register_post_hooks();
|
1138 |
|
1139 |
do_cacheaction( 'add_cacheaction' );
|
1140 |
}
|
1149 |
$super_cache_enabled = false;
|
1150 |
}
|
1151 |
|
1152 |
+
header( 'Vary: ' . ( $wp_cache_gzip_encoding ? 'Accept-Encoding, ' : '' ) . 'Cookie' );
|
1153 |
+
|
|
|
|
|
1154 |
ob_start( 'wp_cache_ob_callback' );
|
1155 |
wp_cache_debug( 'Created output buffer', 4 );
|
1156 |
|
1157 |
// restore old supercache file temporarily
|
1158 |
+
if ( ( $_SERVER['REQUEST_METHOD'] !== 'POST' && empty( $_POST ) ) && $super_cache_enabled && $cache_rebuild_files ) {
|
1159 |
$user_info = wp_cache_get_cookies_values();
|
1160 |
+
|
1161 |
+
if( empty( $user_info )
|
1162 |
+
|| true === apply_filters( 'do_createsupercache', $user_info )
|
1163 |
+
) {
|
1164 |
wpcache_do_rebuild( get_current_url_supercache_dir() );
|
1165 |
+
}
|
1166 |
}
|
1167 |
|
1168 |
schedule_wp_gc();
|
1169 |
}
|
1170 |
|
1171 |
+
function wpsc_register_post_hooks() {
|
1172 |
+
static $done = false;
|
1173 |
+
|
1174 |
+
if ( $done ) {
|
1175 |
+
return;
|
1176 |
+
}
|
1177 |
+
|
1178 |
+
if ( false === $GLOBALS['cache_enabled']
|
1179 |
+
|| ( defined( 'WPLOCKDOWN' ) && constant( 'WPLOCKDOWN' ) != '0' )
|
1180 |
+
) {
|
1181 |
+
$done = true;
|
1182 |
+
return;
|
1183 |
+
}
|
1184 |
+
|
1185 |
+
// Post ID is received
|
1186 |
+
add_action( 'wp_trash_post', 'wp_cache_post_edit', 0 );
|
1187 |
+
add_action( 'publish_post', 'wp_cache_post_edit', 0 );
|
1188 |
+
add_action( 'edit_post', 'wp_cache_post_change', 0 ); // leaving a comment called edit_post
|
1189 |
+
add_action( 'delete_post', 'wp_cache_post_edit', 0 );
|
1190 |
+
add_action( 'publish_phone', 'wp_cache_post_edit', 0 );
|
1191 |
+
|
1192 |
+
// Coment ID is received
|
1193 |
+
add_action( 'trackback_post', 'wp_cache_get_postid_from_comment', 99 );
|
1194 |
+
add_action( 'pingback_post', 'wp_cache_get_postid_from_comment', 99 );
|
1195 |
+
add_action( 'comment_post', 'wp_cache_get_postid_from_comment', 99 );
|
1196 |
+
add_action( 'edit_comment', 'wp_cache_get_postid_from_comment', 99 );
|
1197 |
+
add_action( 'wp_set_comment_status', 'wp_cache_get_postid_from_comment', 99, 2 );
|
1198 |
+
|
1199 |
+
// No post_id is available
|
1200 |
+
add_action( 'switch_theme', 'wp_cache_no_postid', 99 );
|
1201 |
+
add_action( 'edit_user_profile_update', 'wp_cache_no_postid', 99 );
|
1202 |
+
add_action( 'wp_update_nav_menu', 'wp_cache_clear_cache_on_menu' );
|
1203 |
+
add_action( 'clean_post_cache', 'wp_cache_post_edit' );
|
1204 |
+
add_action( 'transition_post_status', 'wpsc_post_transition', 10, 3 );
|
1205 |
+
|
1206 |
+
// Cron hooks
|
1207 |
+
add_action( 'wp_cache_gc','wp_cache_gc_cron' );
|
1208 |
+
add_action( 'wp_cache_gc_watcher', 'wp_cache_gc_watcher' );
|
1209 |
+
|
1210 |
+
$done = true;
|
1211 |
+
}
|
1212 |
+
|
1213 |
function wpcache_do_rebuild( $dir ) {
|
1214 |
global $do_rebuild_list, $cache_path, $wpsc_file_mtimes;
|
1215 |
wp_cache_debug( "wpcache_do_rebuild: doing rebuild for $dir" );
|
1221 |
|
1222 |
$dir = wpsc_get_realpath( $dir );
|
1223 |
if ( ! $dir ) {
|
1224 |
+
wp_cache_debug( 'wpcache_do_rebuild: exiting as directory does not exist.' );
|
1225 |
return false;
|
1226 |
}
|
1227 |
|
1449 |
return true;
|
1450 |
|
1451 |
if( !$mutex ) {
|
1452 |
+
wp_cache_debug( '(writers entry) mutex lock not created. not caching.', 2 );
|
1453 |
return false;
|
1454 |
}
|
1455 |
|
1456 |
if ( $use_flock ) {
|
1457 |
+
wp_cache_debug( 'grabbing lock using flock()', 5 );
|
1458 |
flock($mutex, LOCK_EX);
|
1459 |
} else {
|
1460 |
+
wp_cache_debug( 'grabbing lock using sem_acquire()', 5 );
|
1461 |
@sem_acquire($mutex);
|
1462 |
}
|
1463 |
|
1471 |
return true;
|
1472 |
|
1473 |
if( !$mutex ) {
|
1474 |
+
wp_cache_debug( '(writers exit) mutex lock not created. not caching.', 2 );
|
1475 |
return false;
|
1476 |
}
|
1477 |
|
1478 |
if ( $use_flock ) {
|
1479 |
+
wp_cache_debug( 'releasing lock using flock()', 5 );
|
1480 |
flock( $mutex, LOCK_UN );
|
1481 |
} else {
|
1482 |
+
wp_cache_debug( 'releasing lock using sem_release() and sem_remove()', 5 );
|
1483 |
@sem_release( $mutex );
|
1484 |
if ( defined( "WPSC_REMOVE_SEMAPHORE" ) )
|
1485 |
@sem_remove( $mutex );
|
1595 |
wp_cache_debug( 'DONOTCACHEPAGE defined. Caching disabled.', 2 );
|
1596 |
$cache_this_page = false;
|
1597 |
} elseif ( $wp_cache_no_cache_for_get && ! empty( $_GET ) ) {
|
1598 |
+
wp_cache_debug( 'Non empty GET request. Caching disabled on settings page. ' . wpsc_dump_get_request(), 1 );
|
1599 |
$cache_this_page = false;
|
1600 |
} elseif ( $_SERVER["REQUEST_METHOD"] == 'POST' || !empty( $_POST ) || get_option( 'gzipcompression' ) ) {
|
1601 |
wp_cache_debug( 'Not caching POST request.', 5 );
|
1785 |
if ( isset( $wp_super_cache_query[ 'is_404' ] ) && false == apply_filters( 'wpsupercache_404', false ) ) {
|
1786 |
$new_cache = false;
|
1787 |
if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) {
|
1788 |
+
wp_cache_debug( '404 file not found not cached', 2 );
|
1789 |
wp_cache_add_to_buffer( $buffer, "Page not cached by WP Super Cache. 404." );
|
1790 |
}
|
1791 |
}
|
1793 |
if ( !preg_match( apply_filters( 'wp_cache_eof_tags', '/(<\/html>|<\/rss>|<\/feed>|<\/urlset|<\?xml)/i' ), $buffer ) ) {
|
1794 |
$new_cache = false;
|
1795 |
if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) {
|
1796 |
+
wp_cache_debug( 'No closing html tag. Not caching.', 2 );
|
1797 |
wp_cache_add_to_buffer( $buffer, "Page not cached by WP Super Cache. No closing HTML tag. Check your theme." );
|
1798 |
}
|
1799 |
}
|
1807 |
|
1808 |
if( !wp_cache_writers_entry() ) {
|
1809 |
wp_cache_add_to_buffer( $buffer, "Page not cached by WP Super Cache. Could not get mutex lock." );
|
1810 |
+
wp_cache_debug( 'Could not get mutex lock. Not caching.', 1 );
|
1811 |
return wp_cache_maybe_dynamic( $buffer );
|
1812 |
}
|
1813 |
|
1814 |
if ( $wp_cache_not_logged_in && isset( $wp_super_cache_query[ 'is_feed' ] ) ) {
|
1815 |
+
wp_cache_debug( 'Feed detected. Writing wpcache cache files.', 5 );
|
1816 |
$wp_cache_not_logged_in = false;
|
1817 |
}
|
1818 |
|
1821 |
$dir = get_current_url_supercache_dir();
|
1822 |
$supercachedir = $cache_path . 'supercache/' . preg_replace('/:.*$/', '', $home_url[ 'host' ]);
|
1823 |
if ( ! empty( $_GET ) || isset( $wp_super_cache_query[ 'is_feed' ] ) || ( $super_cache_enabled == true && is_dir( substr( $supercachedir, 0, -1 ) . '.disabled' ) ) ) {
|
1824 |
+
wp_cache_debug( 'Supercache disabled: GET or feed detected or disabled by config.', 2 );
|
1825 |
$super_cache_enabled = false;
|
1826 |
}
|
1827 |
|
1830 |
$supercacheonly = false;
|
1831 |
if( $super_cache_enabled ) {
|
1832 |
if ( wp_cache_get_cookies_values() == '' && empty( $_GET ) ) {
|
1833 |
+
wp_cache_debug( 'Anonymous user detected. Only creating Supercache file.', 3 );
|
1834 |
$supercacheonly = true;
|
1835 |
}
|
1836 |
}
|
1871 |
$dir = wpsc_get_realpath( $dir );
|
1872 |
|
1873 |
if ( ! $dir ) {
|
1874 |
+
wp_cache_debug( 'wp_cache_get_ob: not caching as directory does not exist.' );
|
1875 |
return $buffer;
|
1876 |
}
|
1877 |
|
1888 |
if ( !$supercacheonly ) {
|
1889 |
$fr = @fopen($tmp_wpcache_filename, 'w');
|
1890 |
if (!$fr) {
|
1891 |
+
wp_cache_debug( 'Error. Supercache could not write to ' . str_replace( ABSPATH, '', $cache_path ) . $cache_filename, 1 );
|
1892 |
wp_cache_add_to_buffer( $buffer, "File not cached! Super Cache Couldn't write to: " . str_replace( ABSPATH, '', $cache_path ) . $cache_filename );
|
1893 |
wp_cache_writers_exit();
|
1894 |
return wp_cache_maybe_dynamic( $buffer );
|
1902 |
$tmp_cache_filename = $dir . uniqid( mt_rand(), true ) . '.tmp';
|
1903 |
$fr2 = @fopen( $tmp_cache_filename, 'w' );
|
1904 |
if ( !$fr2 ) {
|
1905 |
+
wp_cache_debug( 'Error. Supercache could not write to ' . str_replace( ABSPATH, '', $tmp_cache_filename ), 1 );
|
1906 |
wp_cache_add_to_buffer( $buffer, "File not cached! Super Cache Couldn't write to: " . str_replace( ABSPATH, '', $tmp_cache_filename ) );
|
1907 |
@fclose( $fr );
|
1908 |
@unlink( $tmp_wpcache_filename );
|
1911 |
} elseif ( ( !isset( $wp_cache_mfunc_enabled ) || $wp_cache_mfunc_enabled == 0 ) && $cache_compression ) { // don't want to store compressed files if using dynamic content
|
1912 |
$gz = @fopen( $tmp_cache_filename . ".gz", 'w');
|
1913 |
if (!$gz) {
|
1914 |
+
wp_cache_debug( 'Error. Supercache could not write to ' . str_replace( ABSPATH, '', $tmp_cache_filename ) . ".gz", 1 );
|
1915 |
wp_cache_add_to_buffer( $buffer, "File not cached! Super Cache Couldn't write to: " . str_replace( ABSPATH, '', $tmp_cache_filename ) . ".gz" );
|
1916 |
@fclose( $fr );
|
1917 |
@unlink( $tmp_wpcache_filename );
|
1936 |
*/
|
1937 |
if ( $wp_cache_mfunc_enabled == 1 ) {
|
1938 |
if ( preg_match( '/<!--mclude|<!--mfunc|<!--dynamic-cached-content-->/', $buffer ) ) { //Dynamic content
|
1939 |
+
wp_cache_debug( 'mfunc/mclude/dynamic-cached-content tags have been retired. Please update your theme. See docs for updates.' );
|
1940 |
wp_cache_add_to_buffer( $buffer, "Warning! Obsolete mfunc/mclude/dynamic-cached-content tags found. Please update your theme. See http://ocaoimh.ie/y/5b for more information." );
|
1941 |
}
|
1942 |
|
1945 |
wp_cache_add_to_buffer( $buffer, 'Super Cache dynamic page detected but late init not set. See the readme.txt for further details.' );
|
1946 |
|
1947 |
if ( $fr ) { // wpcache caching
|
1948 |
+
wp_cache_debug( 'Writing dynamic buffer to wpcache file.' );
|
1949 |
wp_cache_add_to_buffer( $buffer, "Dynamic WPCache Super Cache" );
|
1950 |
fputs( $fr, '<?php die(); ?>' . $buffer );
|
1951 |
} elseif ( isset( $fr2 ) ) { // supercache active
|
1952 |
+
wp_cache_debug( 'Writing dynamic buffer to supercache file.' );
|
1953 |
wp_cache_add_to_buffer( $buffer, "Dynamic Super Cache" );
|
1954 |
fputs( $fr2, $buffer );
|
1955 |
} elseif ( true == $wp_cache_object_cache ) {
|
1961 |
}
|
1962 |
|
1963 |
if ( $cache_compression && $wp_cache_gzip_encoding ) {
|
1964 |
+
wp_cache_debug( 'Gzipping dynamic buffer for display.', 5 );
|
1965 |
wp_cache_add_to_buffer( $buffer, "Compression = gzip" );
|
1966 |
$gzdata = gzencode( $buffer, 6, FORCE_GZIP );
|
1967 |
$gzsize = function_exists( 'mb_strlen' ) ? mb_strlen( $gzdata, '8bit' ) : strlen( $gzdata );
|
1968 |
}
|
1969 |
} else {
|
1970 |
if ( $gz || $wp_cache_gzip_encoding ) {
|
1971 |
+
wp_cache_debug( 'Gzipping buffer.', 5 );
|
1972 |
wp_cache_add_to_buffer( $buffer, "Compression = gzip" );
|
1973 |
$gzdata = gzencode( $buffer, 6, FORCE_GZIP );
|
1974 |
$gzsize = function_exists( 'mb_strlen' ) ? mb_strlen( $gzdata, '8bit' ) : strlen( $gzdata );
|
1977 |
$wp_cache_meta[ 'headers' ][ 'Vary' ] = 'Vary: Accept-Encoding, Cookie';
|
1978 |
// Return uncompressed data & store compressed for later use
|
1979 |
if ( $fr ) {
|
1980 |
+
wp_cache_debug( 'Writing gzipped buffer to wp-cache cache file.', 5 );
|
1981 |
fputs($fr, '<?php die(); ?>' . $gzdata);
|
1982 |
} elseif ( $cache_enabled && $wp_cache_object_cache ) {
|
1983 |
wp_cache_set( $oc_key . ".gz", $gzdata, 'supercache', $cache_max_time );
|
1989 |
wp_cache_set( $oc_key, $buffer, 'supercache', $cache_max_time );
|
1990 |
$added_cache = 1;
|
1991 |
} elseif ( $fr ) {
|
1992 |
+
wp_cache_debug( 'Writing non-gzipped buffer to wp-cache cache file.' );
|
1993 |
fputs($fr, '<?php die(); ?>' . $buffer);
|
1994 |
}
|
1995 |
}
|
1996 |
if ( $fr2 ) {
|
1997 |
+
wp_cache_debug( 'Writing non-gzipped buffer to supercache file.' );
|
1998 |
wp_cache_add_to_buffer( $buffer, "super cache" );
|
1999 |
fputs($fr2, $buffer );
|
2000 |
}
|
2001 |
if ( isset( $gzdata ) && $gz ) {
|
2002 |
+
wp_cache_debug( 'Writing gzipped buffer to supercache file.' );
|
2003 |
fwrite($gz, $gzdata );
|
2004 |
}
|
2005 |
}
|
2010 |
$supercacheonly = false;
|
2011 |
fclose($fr);
|
2012 |
if ( filesize( $tmp_wpcache_filename ) == 0 ) {
|
2013 |
+
wp_cache_debug( "Warning! The file $tmp_wpcache_filename was empty. Did not rename to {$dir}{$cache_filename}", 5 );
|
2014 |
@unlink( $tmp_wpcache_filename );
|
2015 |
} else {
|
2016 |
+
if ( !@rename( $tmp_wpcache_filename, $dir . $cache_filename ) ) {
|
2017 |
if ( false == is_dir( $dir ) )
|
2018 |
@wp_mkdir_p( $dir );
|
2019 |
@unlink( $dir . $cache_filename );
|
2020 |
+
@rename( $tmp_wpcache_filename, $dir . $cache_filename );
|
2021 |
+
}
|
2022 |
+
if ( file_exists( $dir . $cache_filename ) ) {
|
2023 |
+
wp_cache_debug( "Renamed temp wp-cache file to {$dir}{$cache_filename}", 5 );
|
2024 |
+
} else {
|
2025 |
+
wp_cache_debug( "FAILED to rename temp wp-cache file to {$dir}{$cache_filename}", 5 );
|
2026 |
}
|
|
|
2027 |
$added_cache = 1;
|
2028 |
}
|
2029 |
}
|
2031 |
fclose($fr2);
|
2032 |
if ( $wp_cache_front_page_checks && $cache_fname == $supercachedir . $home_url[ 'path' ] . supercache_filename() && !( $wp_cache_is_home ) ) {
|
2033 |
wp_cache_writers_exit();
|
2034 |
+
wp_cache_debug( 'Warning! Not writing another page to front page cache.', 1 );
|
2035 |
return $buffer;
|
2036 |
} elseif ( filesize( $tmp_cache_filename ) == 0 ) {
|
2037 |
wp_cache_debug( "Warning! The file $tmp_cache_filename was empty. Did not rename to {$cache_fname}", 5 );
|
2070 |
}
|
2071 |
wp_cache_writers_exit();
|
2072 |
if ( !headers_sent() && $wp_cache_gzip_encoding && $gzdata) {
|
2073 |
+
wp_cache_debug( 'Writing gzip content headers. Sending buffer to browser', 5 );
|
2074 |
header( 'Content-Encoding: ' . $wp_cache_gzip_encoding );
|
2075 |
header( 'Vary: Accept-Encoding, Cookie' );
|
2076 |
header( 'Content-Length: ' . $gzsize );
|
2077 |
return $gzdata;
|
2078 |
} else {
|
2079 |
+
wp_cache_debug( 'Sending buffer to browser', 5 );
|
2080 |
return $buffer;
|
2081 |
}
|
2082 |
}
|
2105 |
}
|
2106 |
}
|
2107 |
closedir($handle);
|
2108 |
+
do_action( 'wp_cache_cleared' );
|
2109 |
}
|
2110 |
wp_cache_writers_exit();
|
2111 |
}
|
2114 |
|
2115 |
// Don't prune a NULL/empty directory.
|
2116 |
if ( null === $directory || '' === $directory ) {
|
2117 |
+
wp_cache_debug( 'prune_super_cache: directory is blank' );
|
2118 |
return false;
|
2119 |
}
|
2120 |
|
2319 |
* ref: https://wordpress.org/support/topic/fatal-error-while-updating-post-or-publishing-new-one/
|
2320 |
*/
|
2321 |
$wpsc_feed_ttl = 1;
|
2322 |
+
wp_cache_debug( 'wp_cache_shutdown_callback: Plugin not loaded. Setting feed ttl to 60 seconds.' );
|
2323 |
}
|
2324 |
|
2325 |
|
2326 |
if ( false == $new_cache ) {
|
2327 |
+
wp_cache_debug( 'wp_cache_shutdown_callback: No cache file created. Returning.' );
|
2328 |
return false;
|
2329 |
}
|
2330 |
|
2339 |
$wp_cache_meta[ 'headers' ][ $key ] = "$key: $value";
|
2340 |
}
|
2341 |
|
2342 |
+
wp_cache_debug( 'wp_cache_shutdown_callback: collecting meta data.', 2 );
|
2343 |
|
2344 |
if (!isset( $response['Last-Modified'] )) {
|
2345 |
$value = gmdate('D, d M Y H:i:s') . ' GMT';
|
2397 |
|
2398 |
if ( $cache_enabled && !$supercacheonly && $new_cache ) {
|
2399 |
if( !isset( $wp_cache_meta[ 'dynamic' ] ) && $wp_cache_gzip_encoding && !in_array( 'Content-Encoding: ' . $wp_cache_gzip_encoding, $wp_cache_meta[ 'headers' ] ) ) {
|
2400 |
+
wp_cache_debug( 'Sending gzip headers.', 2 );
|
2401 |
$wp_cache_meta[ 'headers' ][ 'Content-Encoding' ] = 'Content-Encoding: ' . $wp_cache_gzip_encoding;
|
2402 |
$wp_cache_meta[ 'headers' ][ 'Vary' ] = 'Vary: Accept-Encoding, Cookie';
|
2403 |
}
|
2447 |
}
|
2448 |
global $time_to_gc_cache;
|
2449 |
if( isset( $time_to_gc_cache ) && $time_to_gc_cache == 1 ) {
|
2450 |
+
wp_cache_debug( 'Executing wp_cache_gc action.', 3 );
|
2451 |
do_action( 'wp_cache_gc' );
|
2452 |
}
|
2453 |
}
|
2502 |
$super_cache_enabled = 0; // don't remove the super cache static file until comment is approved
|
2503 |
define( 'DONOTDELETECACHE', 1 );
|
2504 |
} else {
|
2505 |
+
wp_cache_debug( 'Moderated ping or trackback. Not deleting cache files..', 4 );
|
2506 |
define( 'DONOTDELETECACHE', 1 );
|
2507 |
return $postid;
|
2508 |
}
|
2515 |
wp_cache_debug( "Post $postid changed. Update cache.", 4 );
|
2516 |
return wp_cache_post_change( $postid );
|
2517 |
} else {
|
2518 |
+
wp_cache_debug( 'Unknown post changed. Update cache.', 4 );
|
2519 |
return wp_cache_post_change( wp_cache_post_id() );
|
2520 |
}
|
2521 |
}
|
2533 |
reset_oc_version();
|
2534 |
} else {
|
2535 |
if ( $blog_id == 0 ) {
|
2536 |
+
wp_cache_debug( 'Clearing all cached files in wp_cache_clear_cache()', 4 );
|
2537 |
prune_super_cache( $cache_path . 'supercache/', true );
|
2538 |
prune_super_cache( $cache_path, true );
|
2539 |
} else {
|
2542 |
prune_super_cache( $cache_path . 'blogs/', true );
|
2543 |
}
|
2544 |
}
|
2545 |
+
do_action( 'wp_cache_cleared' );
|
2546 |
}
|
2547 |
|
2548 |
function wpsc_delete_post_archives( $post ) {
|
2571 |
}
|
2572 |
|
2573 |
wpsc_delete_url_cache( $term_url );
|
2574 |
+
wp_cache_debug( 'wpsc_delete_post_archives: deleting cache of taxonomies: ' . $term_url );
|
2575 |
}
|
2576 |
}
|
2577 |
|
2586 |
|
2587 |
if ( $archive_url ) {
|
2588 |
wpsc_delete_url_cache( $archive_url );
|
2589 |
+
wp_cache_debug( 'wpsc_delete_post_archives: deleting cache of post type archive: ' . $archive_url );
|
2590 |
}
|
2591 |
|
2592 |
// Author archive page
|
2593 |
$author_url = get_author_posts_url( $post->post_author );
|
2594 |
if ( $author_url ) {
|
2595 |
wpsc_delete_url_cache( $author_url );
|
2596 |
+
wp_cache_debug( 'wpsc_delete_post_archives: deleting cache of author archive: ' . $author_url );
|
2597 |
}
|
2598 |
}
|
2599 |
|
2607 |
$category_base = trailingslashit( $category_base ); // paranoid much?
|
2608 |
foreach ($categories as $cat) {
|
2609 |
prune_super_cache ( get_supercache_dir() . $category_base . $cat->slug . '/', true );
|
2610 |
+
wp_cache_debug( 'wpsc_post_transition: deleting category: ' . get_supercache_dir() . $category_base . $cat->slug . '/' );
|
2611 |
}
|
2612 |
}
|
2613 |
$posttags = get_the_tags($post->ID);
|
2618 |
$tag_base = trailingslashit( str_replace( '..', '', $tag_base ) ); // maybe!
|
2619 |
foreach ($posttags as $tag) {
|
2620 |
prune_super_cache( get_supercache_dir() . $tag_base . $tag->slug . '/', true );
|
2621 |
+
wp_cache_debug( 'wpsc_post_transition: deleting tag: ' . get_supercache_dir() . $tag_base . $tag->slug . '/' );
|
2622 |
}
|
2623 |
}
|
2624 |
}
|
2627 |
if (
|
2628 |
($old_status == 'publish' && $new_status != 'publish' ) // post unpublished
|
2629 |
||
|
2630 |
+
($new_status == 'publish') // post published or updated
|
2631 |
) {
|
2632 |
//wpsc_delete_cats_tags( $post );
|
2633 |
wpsc_delete_post_archives( $post );
|
2634 |
$post_url = get_permalink( $post->ID );
|
2635 |
wpsc_delete_url_cache( $post_url );
|
2636 |
+
wp_cache_debug( 'wpsc_post_transition: deleting cache of post: ' . $post_url );
|
2637 |
}
|
2638 |
}
|
2639 |
|
2654 |
// Some users are inexplicibly seeing this error on scheduled posts.
|
2655 |
// define this constant to disable the post status check.
|
2656 |
if ( false == defined( 'WPSCFORCEUPDATE' ) && !in_array($post->post_status, array( 'publish', 'private' ) ) ) {
|
2657 |
+
wp_cache_debug( 'wp_cache_post_edit: draft post, not deleting any cache files. status: ' . $post->post_status, 4 );
|
2658 |
return $post_id;
|
2659 |
}
|
2660 |
|
2719 |
// Some users are inexplicibly seeing this error on scheduled posts.
|
2720 |
// define this constant to disable the post status check.
|
2721 |
if ( false == defined( 'WPSCFORCEUPDATE' ) && is_object( $post ) && !in_array($post->post_status, array( 'publish', 'private' ) ) ) {
|
2722 |
+
wp_cache_debug( 'wp_cache_post_change: draft post, not deleting any cache files.', 4 );
|
2723 |
return $post_id;
|
2724 |
}
|
2725 |
$last_processed = $post_id;
|
2727 |
if( !wp_cache_writers_entry() )
|
2728 |
return $post_id;
|
2729 |
|
2730 |
+
if (
|
2731 |
+
isset( $wp_cache_refresh_single_only ) &&
|
2732 |
+
$wp_cache_refresh_single_only &&
|
2733 |
+
(
|
2734 |
+
isset( $_SERVER['HTTP_REFERER'] ) &&
|
2735 |
+
strpos( $_SERVER['HTTP_REFERER'], 'edit-comments.php' ) ||
|
2736 |
+
strpos( $_SERVER['REQUEST_URI'], 'wp-comments-post.php' )
|
2737 |
+
)
|
2738 |
+
) {
|
2739 |
if ( defined( 'DONOTDELETECACHE' ) ) {
|
2740 |
wp_cache_debug( "wp_cache_post_change: comment detected and it's moderated or spam. Not deleting cached files.", 4 );
|
2741 |
return $post_id;
|
2742 |
} else {
|
2743 |
+
wp_cache_debug( 'wp_cache_post_change: comment detected. only deleting post page.', 4 );
|
2744 |
$all = false;
|
2745 |
}
|
2746 |
} else {
|
2759 |
$dir = get_supercache_dir();
|
2760 |
// make sure the front page has a rebuild file
|
2761 |
if ( false == wp_cache_post_id_gc( $post_id, $all ) ) {
|
2762 |
+
wp_cache_debug( 'wp_cache_post_change: not deleting any cache files as GC of post returned false' );
|
2763 |
wp_cache_writers_exit();
|
2764 |
return false;
|
2765 |
}
|
2766 |
if ( $all == true ) {
|
2767 |
+
wp_cache_debug( 'Post change: supercache enabled: deleting cache files in ' . $dir );
|
2768 |
wpsc_rebuild_files( $dir );
|
2769 |
do_action( 'gc_cache', 'prune', 'homepage' );
|
2770 |
if ( get_option( 'show_on_front' ) == 'page' ) {
|
2771 |
+
wp_cache_debug( 'Post change: deleting page_on_front and page_for_posts pages.', 4 );
|
2772 |
+
wp_cache_debug( 'Post change: page_on_front ' . get_option( 'page_on_front' ), 4 );
|
2773 |
$permalink = trailingslashit( str_replace( get_option( 'home' ), '', get_permalink( get_option( 'page_for_posts' ) ) ) );
|
2774 |
+
wp_cache_debug( 'Post change: Deleting files in: ' . str_replace( '//', '/', $dir . $permalink ) );
|
2775 |
wpsc_rebuild_files( $dir . $permalink );
|
2776 |
do_action( 'gc_cache', 'prune', $permalink );
|
2777 |
}
|
2778 |
} else {
|
2779 |
+
wp_cache_debug( 'wp_cache_post_change: not deleting all pages.', 4 );
|
2780 |
}
|
2781 |
|
2782 |
wp_cache_debug( "wp_cache_post_change: checking {$blog_cache_dir}meta/", 4 );
|
wp-cache.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: WP Super Cache
|
4 |
Plugin URI: https://wordpress.org/plugins/wp-super-cache/
|
5 |
Description: Very fast caching plugin for WordPress.
|
6 |
-
Version: 1.
|
7 |
Author: Automattic
|
8 |
Author URI: https://automattic.com/
|
9 |
License: GPL2+
|
@@ -29,7 +29,9 @@ Text Domain: wp-super-cache
|
|
29 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
30 |
*/
|
31 |
|
32 |
-
|
|
|
|
|
33 |
|
34 |
function wpsc_init() {
|
35 |
global $wp_cache_config_file, $wp_cache_config_file_sample, $wp_cache_file, $wp_cache_check_wp_config, $wp_cache_link;
|
@@ -59,6 +61,13 @@ function wpsc_init() {
|
|
59 |
|
60 |
wpsc_init();
|
61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
if( !@include($wp_cache_config_file) ) {
|
63 |
get_wpcachehome();
|
64 |
$wp_cache_config_file_sample = WPCACHEHOME . 'wp-cache-config-sample.php';
|
@@ -72,10 +81,12 @@ if ( class_exists( 'WP_REST_Controller' ) ) {
|
|
72 |
include( dirname( __FILE__ ) . '/rest/load.php' );
|
73 |
}
|
74 |
|
75 |
-
function
|
76 |
load_plugin_textdomain( 'wp-super-cache', false, basename( dirname( __FILE__ ) ) . '/languages' );
|
|
|
|
|
77 |
}
|
78 |
-
add_action( 'init', '
|
79 |
|
80 |
function wp_cache_set_home() {
|
81 |
global $wp_cache_is_home;
|
@@ -112,7 +123,7 @@ function wpsupercache_uninstall() {
|
|
112 |
|
113 |
wp_cache_remove_index();
|
114 |
|
115 |
-
if (
|
116 |
@unlink( $cache_path . '.htaccess' );
|
117 |
@unlink( $cache_path . 'meta' );
|
118 |
@unlink( $cache_path . 'supercache' );
|
@@ -130,13 +141,19 @@ if ( is_admin() ) {
|
|
130 |
|
131 |
function wpsupercache_deactivate() {
|
132 |
global $wp_cache_config_file, $wp_cache_link, $cache_path;
|
133 |
-
|
|
|
134 |
unlink( $wp_cache_link );
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
|
|
|
|
|
|
|
|
|
|
140 |
wp_clear_scheduled_hook( 'wp_cache_check_site_hook' );
|
141 |
wp_clear_scheduled_hook( 'wp_cache_gc' );
|
142 |
wp_clear_scheduled_hook( 'wp_cache_gc_watcher' );
|
@@ -199,6 +216,7 @@ add_action( 'network_admin_menu', 'wp_cache_network_pages' );
|
|
199 |
function wp_cache_manager_error_checks() {
|
200 |
global $wp_cache_debug, $wp_cache_cron_check, $cache_enabled, $super_cache_enabled, $wp_cache_config_file, $wp_cache_mobile_browsers, $wp_cache_mobile_prefixes, $wp_cache_mobile_browsers, $wp_cache_mobile_enabled, $wp_cache_mod_rewrite;
|
201 |
global $dismiss_htaccess_warning, $dismiss_readable_warning, $dismiss_gc_warning, $wp_cache_shutdown_gc, $is_nginx;
|
|
|
202 |
|
203 |
if ( !wpsupercache_site_admin() )
|
204 |
return false;
|
@@ -267,7 +285,7 @@ function wp_cache_manager_error_checks() {
|
|
267 |
if ( false == function_exists( 'wpsc_deep_replace' ) ) {
|
268 |
$msg = __( 'Warning! You must set WP_CACHE and WPCACHEHOME in your wp-config.php for this plugin to work correctly:' ) . '<br />';
|
269 |
$msg .= "<code>define( 'WP_CACHE', true );</code><br />";
|
270 |
-
$msg .= "<code>define( 'WPCACHEHOME', '" . dirname( __FILE__ ) . "' );</code><br />";
|
271 |
wp_die( $msg );
|
272 |
}
|
273 |
|
@@ -360,7 +378,11 @@ function wp_cache_manager_error_checks() {
|
|
360 |
}
|
361 |
|
362 |
if ( ! $is_nginx && function_exists( "is_main_site" ) && true == is_main_site() ) {
|
363 |
-
|
|
|
|
|
|
|
|
|
364 |
$scrules = implode( "\n", extract_from_markers( $home_path.'.htaccess', 'WPSuperCache' ) );
|
365 |
if ( $cache_enabled && $wp_cache_mod_rewrite && !$wp_cache_mobile_enabled && strpos( $scrules, addcslashes( str_replace( ', ', '|', $wp_cache_mobile_browsers ), ' ' ) ) ) {
|
366 |
echo '<div class="notice notice-warning"><h3>' . __( 'Mobile rewrite rules detected', 'wp-super-cache' ) . "</h3>";
|
@@ -720,7 +742,7 @@ function wp_cache_manager() {
|
|
720 |
} elseif ( function_exists( 'lite_detection_ua_contains' ) ) {
|
721 |
$wp_cache_mobile_browsers = explode( '|', lite_detection_ua_contains() );
|
722 |
} else {
|
723 |
-
$wp_cache_mobile_browsers = array( '2.0 MMP', '240x320', '400X240', 'AvantGo', 'BlackBerry', 'Blazer', 'Cellphone', 'Danger', 'DoCoMo', 'Elaine/3.0', 'EudoraWeb', 'Googlebot-Mobile', 'hiptop', 'IEMobile', 'KYOCERA/WX310K', 'LG/U990', 'MIDP-2.', 'MMEF20', 'MOT-V', 'NetFront', 'Newt', 'Nintendo Wii', 'Nitro', 'Nokia', 'Opera Mini', 'Palm', 'PlayStation Portable', 'portalmmm', 'Proxinet', 'ProxiNet', 'SHARP-TQ-GX10', 'SHG-i900', 'Small', 'SonyEricsson', 'Symbian OS', 'SymbianOS', 'TS21i-10', 'UP.Browser', 'UP.Link', 'webOS', 'Windows CE', 'WinWAP', 'YahooSeeker/M1A1-R2D2', 'iPhone', 'iPod', 'Android', 'BlackBerry9530', 'LG-TU915 Obigo', 'LGE VX', 'webOS', 'Nokia5800' );
|
724 |
}
|
725 |
if ( function_exists( "lite_detection_ua_prefixes" ) ) {
|
726 |
$wp_cache_mobile_prefixes = lite_detection_ua_prefixes();
|
@@ -1251,10 +1273,10 @@ table.wpsc-settings-table {
|
|
1251 |
<p><?php _e( 'Caching is only one part of making a website faster. Here are some other plugins that will help:', 'wp-super-cache' ); ?></p>
|
1252 |
<ul style="list-style: square; margin-left: 2em;">
|
1253 |
<li><?php printf( __( '<a href="%s">Jetpack</a> provides everything you need to build a successful WordPress website including an image/photo CDN (free) and a video hosting service (paid).', 'wp-super-cache' ), 'https://jetpack.com/redirect/?source=jitm-wpsc-recommended' ); ?></li>
|
1254 |
-
<li><?php printf( __( '<a href="%s">Yahoo! Yslow</a>
|
1255 |
<li><?php printf( __( '<a href="%s">Use Google Libraries</a> allows you to load some commonly used Javascript libraries from Google webservers. Ironically, it may reduce your Yslow score.', 'wp-super-cache' ), 'https://wordpress.org/plugins/use-google-libraries/' ); ?></li>
|
1256 |
<li><?php printf( __( '<strong>Advanced users only:</strong> Install an object cache. Choose from <a href="%s">Memcached</a>, <a href="%s">XCache</a>, <a href="%s">eAcccelerator</a> and others.', 'wp-super-cache' ), 'https://wordpress.org/plugins/memcached/', 'https://neosmart.net/WP/XCache/', 'https://neosmart.net/WP/eAccelerator/' ); ?></li>
|
1257 |
-
<li><?php printf( __( '<a href="%s">
|
1258 |
</ul>
|
1259 |
|
1260 |
<?php
|
@@ -1359,17 +1381,20 @@ function wpsc_admin_tabs( $current = 0 ) {
|
|
1359 |
}
|
1360 |
|
1361 |
function wsc_mod_rewrite() {
|
1362 |
-
global $valid_nonce, $cache_path
|
1363 |
|
1364 |
-
if ( $is_nginx ) {
|
1365 |
return false;
|
1366 |
}
|
1367 |
|
1368 |
-
if ( defined( 'WPSC_DISABLE_HTACCESS_UPDATE' ) )
|
1369 |
return false;
|
|
|
1370 |
|
1371 |
-
if (
|
1372 |
return false;
|
|
|
|
|
1373 |
?>
|
1374 |
<a name="modrewrite"></a><fieldset class="options">
|
1375 |
<h3><?php _e( 'Mod Rewrite Rules', 'wp-super-cache' ); ?></h3>
|
@@ -1969,31 +1994,39 @@ function wpsc_update_debug_settings() {
|
|
1969 |
);
|
1970 |
}
|
1971 |
|
1972 |
-
if ( isset( $_POST[ 'wpsc_delete_log' ] ) && $wp_cache_debug_log != '' ) {
|
1973 |
@unlink( $cache_path . $wp_cache_debug_log );
|
1974 |
extract( wpsc_create_debug_log( $wp_cache_debug_log, $wp_cache_debug_username ) ); // $wp_cache_debug_log, $wp_cache_debug_username
|
1975 |
-
} elseif ( isset( $_POST[ 'wp_super_cache_debug' ] ) ) {
|
1976 |
-
if ( ! isset( $wp_cache_debug_log ) || $wp_cache_debug_log == '' ) {
|
1977 |
-
extract( wpsc_create_debug_log() ); // $wp_cache_debug_log, $wp_cache_debug_username
|
1978 |
-
} elseif ( ! file_exists( $cache_path . $wp_cache_debug_log ) ) { // make sure debug log exists before toggling debugging
|
1979 |
-
extract( wpsc_create_debug_log( $wp_cache_debug_log, $wp_cache_debug_username ) ); // $wp_cache_debug_log, $wp_cache_debug_username
|
1980 |
-
}
|
1981 |
-
$wp_super_cache_debug = (int) $_POST[ 'wp_super_cache_debug' ];
|
1982 |
-
wp_cache_setting( 'wp_super_cache_debug', $wp_super_cache_debug );
|
1983 |
}
|
1984 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1985 |
if ( isset( $_POST[ 'wp_cache_debug' ] ) ) {
|
1986 |
wp_cache_setting( 'wp_cache_debug_username', $wp_cache_debug_username );
|
1987 |
wp_cache_setting( 'wp_cache_debug_log', $wp_cache_debug_log );
|
1988 |
$wp_super_cache_comments = isset( $_POST[ 'wp_super_cache_comments' ] ) ? 1 : 0;
|
1989 |
wp_cache_setting( 'wp_super_cache_comments', $wp_super_cache_comments );
|
1990 |
-
|
|
|
|
|
|
|
|
|
1991 |
wp_cache_setting( 'wp_cache_debug_ip', $wp_cache_debug_ip );
|
1992 |
$wp_super_cache_front_page_check = isset( $_POST[ 'wp_super_cache_front_page_check' ] ) ? 1 : 0;
|
1993 |
wp_cache_setting( 'wp_super_cache_front_page_check', $wp_super_cache_front_page_check );
|
1994 |
$wp_super_cache_front_page_clear = isset( $_POST[ 'wp_super_cache_front_page_clear' ] ) ? 1 : 0;
|
1995 |
wp_cache_setting( 'wp_super_cache_front_page_clear', $wp_super_cache_front_page_clear );
|
1996 |
-
|
|
|
|
|
|
|
|
|
1997 |
wp_cache_setting( 'wp_super_cache_front_page_text', $wp_super_cache_front_page_text );
|
1998 |
$wp_super_cache_front_page_notification = isset( $_POST[ 'wp_super_cache_front_page_notification' ] ) ? 1 : 0;
|
1999 |
wp_cache_setting( 'wp_super_cache_front_page_notification', $wp_super_cache_front_page_notification );
|
@@ -2041,7 +2074,8 @@ function wp_cache_debug_settings() {
|
|
2041 |
|
2042 |
echo '<form name="wpsc_delete" action="" method="post">';
|
2043 |
wp_nonce_field('wp-cache');
|
2044 |
-
|
|
|
2045 |
echo "</form>";
|
2046 |
echo '<form name="wpsc_delete" action="" method="post">';
|
2047 |
if ( ! isset( $wp_super_cache_debug ) || $wp_super_cache_debug == 0 ) {
|
@@ -2085,10 +2119,12 @@ function wp_cache_debug_settings() {
|
|
2085 |
function wp_cache_enable() {
|
2086 |
global $wp_cache_config_file, $cache_enabled;
|
2087 |
|
2088 |
-
if( wp_cache_replace_line('
|
2089 |
-
|
2090 |
}
|
2091 |
|
|
|
|
|
2092 |
if ( wpsc_set_default_gc() ) {
|
2093 |
// gc might not be scheduled, check and schedule
|
2094 |
$timestamp = wp_next_scheduled( 'wp_cache_gc' );
|
@@ -2101,59 +2137,80 @@ function wp_cache_enable() {
|
|
2101 |
function wp_cache_disable() {
|
2102 |
global $wp_cache_config_file, $cache_enabled;
|
2103 |
|
|
|
|
|
|
|
|
|
|
|
|
|
2104 |
wp_clear_scheduled_hook( 'wp_cache_check_site_hook' );
|
2105 |
wp_clear_scheduled_hook( 'wp_cache_gc' );
|
2106 |
wp_clear_scheduled_hook( 'wp_cache_gc_watcher' );
|
2107 |
-
if (wp_cache_replace_line('^ *\$cache_enabled', '$cache_enabled = false;', $wp_cache_config_file)) {
|
2108 |
-
$cache_enabled = false;
|
2109 |
-
}
|
2110 |
}
|
|
|
2111 |
function wp_super_cache_enable() {
|
2112 |
global $supercachedir, $wp_cache_config_file, $super_cache_enabled;
|
2113 |
|
2114 |
-
if(
|
2115 |
-
|
2116 |
-
|
2117 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
2118 |
} else {
|
2119 |
-
@rename( $supercachedir .
|
2120 |
}
|
2121 |
-
|
2122 |
-
$super_cache_enabled = true;
|
2123 |
}
|
2124 |
|
2125 |
function wp_super_cache_disable() {
|
2126 |
global $cache_path, $supercachedir, $wp_cache_config_file, $super_cache_enabled;
|
2127 |
|
2128 |
-
wp_cache_replace_line('
|
2129 |
-
|
2130 |
-
|
|
|
2131 |
$super_cache_enabled = false;
|
|
|
|
|
|
|
|
|
2132 |
sleep( 1 ); // allow existing processes to write to the supercachedir and then delete it
|
2133 |
-
if (function_exists
|
2134 |
prune_super_cache( $cache_path, true );
|
2135 |
}
|
|
|
|
|
|
|
|
|
2136 |
}
|
2137 |
|
2138 |
function wp_cache_is_enabled() {
|
2139 |
global $wp_cache_config_file;
|
2140 |
|
2141 |
-
if(get_option('gzipcompression')) {
|
2142 |
-
echo
|
2143 |
return false;
|
2144 |
}
|
2145 |
-
|
2146 |
-
|
2147 |
-
|
|
|
2148 |
return true;
|
|
|
2149 |
}
|
|
|
2150 |
return false;
|
2151 |
}
|
2152 |
|
2153 |
function wp_cache_remove_index() {
|
2154 |
global $cache_path;
|
2155 |
|
2156 |
-
if (
|
2157 |
return;
|
2158 |
}
|
2159 |
|
@@ -2267,6 +2324,9 @@ function wp_cache_add_index_protection() {
|
|
2267 |
add_site_option( 'wp_super_cache_index_detected', 1 ); // only show this once
|
2268 |
}
|
2269 |
}
|
|
|
|
|
|
|
2270 |
insert_with_markers( $cache_path . '.htaccess', "INDEX", array( 'Options -Indexes' ) );
|
2271 |
}
|
2272 |
|
@@ -2829,6 +2889,8 @@ function wpsc_dirsize($directory, $sizes) {
|
|
2829 |
function wp_cache_clean_cache( $file_prefix, $all = false ) {
|
2830 |
global $cache_path, $supercachedir, $blog_cache_dir, $wp_cache_object_cache;
|
2831 |
|
|
|
|
|
2832 |
if ( $wp_cache_object_cache && function_exists( "reset_oc_version" ) )
|
2833 |
reset_oc_version();
|
2834 |
|
@@ -3137,6 +3199,8 @@ function wpsc_get_logged_in_cookie() {
|
|
3137 |
|
3138 |
function wpsc_get_htaccess_info() {
|
3139 |
global $wp_cache_mobile_enabled, $wp_cache_mobile_prefixes, $wp_cache_mobile_browsers, $wp_cache_disable_utf8;
|
|
|
|
|
3140 |
if ( isset( $_SERVER[ "PHP_DOCUMENT_ROOT" ] ) ) {
|
3141 |
$document_root = $_SERVER[ "PHP_DOCUMENT_ROOT" ];
|
3142 |
$apache_root = $_SERVER[ "PHP_DOCUMENT_ROOT" ];
|
@@ -3165,7 +3229,9 @@ function wpsc_get_htaccess_info() {
|
|
3165 |
$home_path = get_home_path();
|
3166 |
$home_root = parse_url(get_bloginfo('url'));
|
3167 |
$home_root = isset( $home_root[ 'path' ] ) ? trailingslashit( $home_root[ 'path' ] ) : '/';
|
3168 |
-
if (
|
|
|
|
|
3169 |
$home_root == '/' &&
|
3170 |
$home_path != $_SERVER[ 'DOCUMENT_ROOT' ]
|
3171 |
) {
|
@@ -3191,7 +3257,7 @@ function wpsc_get_htaccess_info() {
|
|
3191 |
$condition_rules[] = "RewriteCond %{REQUEST_URI} !^.*//.*$";
|
3192 |
}
|
3193 |
$condition_rules[] = "RewriteCond %{REQUEST_METHOD} !POST";
|
3194 |
-
$condition_rules[] = "RewriteCond %{QUERY_STRING}
|
3195 |
$condition_rules[] = "RewriteCond %{HTTP:Cookie} !^.*(comment_author_|" . wpsc_get_logged_in_cookie() . "|wp-postpass_).*$";
|
3196 |
$condition_rules[] = "RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\\\"]+ [NC]";
|
3197 |
$condition_rules[] = "RewriteCond %{HTTP:Profile} !^[a-z0-9\\\"]+ [NC]";
|
@@ -3264,7 +3330,7 @@ function wp_cron_preload_cache() {
|
|
3264 |
|
3265 |
if ( get_option( 'preload_cache_stop' ) ) {
|
3266 |
delete_option( 'preload_cache_stop' );
|
3267 |
-
wp_cache_debug(
|
3268 |
return true;
|
3269 |
}
|
3270 |
|
@@ -3272,10 +3338,10 @@ function wp_cron_preload_cache() {
|
|
3272 |
sleep( 3 + mt_rand( 1, 5 ) );
|
3273 |
if ( @file_exists( $mutex ) ) {
|
3274 |
if ( @filemtime( $mutex ) > ( time() - 600 ) ) {
|
3275 |
-
wp_cache_debug(
|
3276 |
return true;
|
3277 |
} else {
|
3278 |
-
wp_cache_debug(
|
3279 |
@unlink( $mutex );
|
3280 |
}
|
3281 |
}
|
@@ -3284,7 +3350,7 @@ function wp_cron_preload_cache() {
|
|
3284 |
|
3285 |
$counter = get_option( 'preload_cache_counter' );
|
3286 |
if ( is_array( $counter ) == false ) {
|
3287 |
-
wp_cache_debug(
|
3288 |
$counter = array( 'c' => 0, 't' => time() );
|
3289 |
update_option( 'preload_cache_counter', $counter );
|
3290 |
}
|
@@ -3300,7 +3366,7 @@ function wp_cron_preload_cache() {
|
|
3300 |
wp_mail( get_option( 'admin_email' ), sprintf( __( '[%1$s] Cache Preload Started', 'wp-super-cache' ), home_url(), '' ), ' ' );
|
3301 |
|
3302 |
if ( $wp_cache_preload_posts == 'all' || $c < $wp_cache_preload_posts ) {
|
3303 |
-
wp_cache_debug(
|
3304 |
$permalink_counter_msg = $cache_path . "preload_permalink.txt";
|
3305 |
if ( isset( $wp_cache_preload_taxonomies ) && $wp_cache_preload_taxonomies ) {
|
3306 |
$taxonomies = apply_filters( 'wp_cache_preload_taxonomies', array( 'post_tag' => 'tag', 'category' => 'category' ) );
|
@@ -3345,7 +3411,7 @@ function wp_cron_preload_cache() {
|
|
3345 |
wp_cache_debug( "wp_cron_preload_cache: fetched $url", 5 );
|
3346 |
sleep( 1 );
|
3347 |
if ( @file_exists( $cache_path . "stop_preload.txt" ) ) {
|
3348 |
-
wp_cache_debug(
|
3349 |
@unlink( $mutex );
|
3350 |
@unlink( $cache_path . "stop_preload.txt" );
|
3351 |
@unlink( $taxonomy_filename );
|
@@ -3405,7 +3471,7 @@ function wp_cron_preload_cache() {
|
|
3405 |
@fclose( $fp );
|
3406 |
}
|
3407 |
if ( @file_exists( $cache_path . "stop_preload.txt" ) ) {
|
3408 |
-
wp_cache_debug(
|
3409 |
@unlink( $mutex );
|
3410 |
@unlink( $cache_path . "stop_preload.txt" );
|
3411 |
update_option( 'preload_cache_counter', array( 'c' => 0, 't' => time() ) );
|
@@ -3422,7 +3488,7 @@ function wp_cron_preload_cache() {
|
|
3422 |
if ( $wp_cache_preload_email_me && ( $wp_cache_preload_email_volume == 'medium' || $wp_cache_preload_email_volume == 'many' ) )
|
3423 |
wp_mail( get_option( 'admin_email' ), sprintf( __( '[%1$s] %2$d posts refreshed', 'wp-super-cache' ), home_url(), ($c+100) ), __( "Refreshed the following posts:", 'wp-super-cache' ) . "\n$msg" );
|
3424 |
if ( defined( 'DOING_CRON' ) ) {
|
3425 |
-
wp_cache_debug(
|
3426 |
wp_schedule_single_event( time() + 30, 'wp_cache_preload_hook' );
|
3427 |
}
|
3428 |
} else {
|
@@ -3814,14 +3880,9 @@ function update_mod_rewrite_rules( $add_rules = true ) {
|
|
3814 |
}
|
3815 |
|
3816 |
$generated_rules = wpsc_get_htaccess_info();
|
|
|
3817 |
|
3818 |
-
|
3819 |
-
$rules = $generated_rules[ 'rules' ];
|
3820 |
-
} else {
|
3821 |
-
$rules = '';
|
3822 |
-
}
|
3823 |
-
|
3824 |
-
$existing_rules = implode( "\n", extract_from_markers( $home_path . '.htaccess', 'WPSuperCache' ) );
|
3825 |
|
3826 |
if ( $existing_rules == $rules ) {
|
3827 |
$update_mod_rewrite_rules_error = "rules have not changed";
|
@@ -3833,6 +3894,10 @@ function update_mod_rewrite_rules( $add_rules = true ) {
|
|
3833 |
return false;
|
3834 |
}
|
3835 |
|
|
|
|
|
|
|
|
|
3836 |
$url = trailingslashit( get_bloginfo( 'url' ) );
|
3837 |
$original_page = wp_remote_get( $url, array( 'timeout' => 60, 'blocking' => true ) );
|
3838 |
if ( is_wp_error( $original_page ) ) {
|
3 |
Plugin Name: WP Super Cache
|
4 |
Plugin URI: https://wordpress.org/plugins/wp-super-cache/
|
5 |
Description: Very fast caching plugin for WordPress.
|
6 |
+
Version: 1.6.0
|
7 |
Author: Automattic
|
8 |
Author URI: https://automattic.com/
|
9 |
License: GPL2+
|
29 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
30 |
*/
|
31 |
|
32 |
+
if ( ! function_exists( 'wp_cache_phase2' ) ) {
|
33 |
+
require_once( dirname( __FILE__ ) . '/wp-cache-phase2.php');
|
34 |
+
}
|
35 |
|
36 |
function wpsc_init() {
|
37 |
global $wp_cache_config_file, $wp_cache_config_file_sample, $wp_cache_file, $wp_cache_check_wp_config, $wp_cache_link;
|
61 |
|
62 |
wpsc_init();
|
63 |
|
64 |
+
/**
|
65 |
+
* WP-CLI requires explicit declaration of global variables.
|
66 |
+
* It's minimal list of global variables.
|
67 |
+
*/
|
68 |
+
global $super_cache_enabled, $cache_enabled, $wp_cache_home_path, $cache_path;
|
69 |
+
global $wp_cache_config_file, $wp_cache_config_file_sample;
|
70 |
+
|
71 |
if( !@include($wp_cache_config_file) ) {
|
72 |
get_wpcachehome();
|
73 |
$wp_cache_config_file_sample = WPCACHEHOME . 'wp-cache-config-sample.php';
|
81 |
include( dirname( __FILE__ ) . '/rest/load.php' );
|
82 |
}
|
83 |
|
84 |
+
function wp_super_cache_init_action() {
|
85 |
load_plugin_textdomain( 'wp-super-cache', false, basename( dirname( __FILE__ ) ) . '/languages' );
|
86 |
+
|
87 |
+
wpsc_register_post_hooks();
|
88 |
}
|
89 |
+
add_action( 'init', 'wp_super_cache_init_action' );
|
90 |
|
91 |
function wp_cache_set_home() {
|
92 |
global $wp_cache_is_home;
|
123 |
|
124 |
wp_cache_remove_index();
|
125 |
|
126 |
+
if ( ! empty( $cache_path ) ) {
|
127 |
@unlink( $cache_path . '.htaccess' );
|
128 |
@unlink( $cache_path . 'meta' );
|
129 |
@unlink( $cache_path . 'supercache' );
|
141 |
|
142 |
function wpsupercache_deactivate() {
|
143 |
global $wp_cache_config_file, $wp_cache_link, $cache_path;
|
144 |
+
|
145 |
+
if ( file_exists( $wp_cache_link ) ) {
|
146 |
unlink( $wp_cache_link );
|
147 |
+
}
|
148 |
+
|
149 |
+
if ( ! empty( $cache_path ) ) {
|
150 |
+
prune_super_cache( $cache_path, true );
|
151 |
+
wp_cache_remove_index();
|
152 |
+
@unlink( $cache_path . '.htaccess' );
|
153 |
+
@unlink( $cache_path . 'meta' );
|
154 |
+
@unlink( $cache_path . 'supercache' );
|
155 |
+
}
|
156 |
+
|
157 |
wp_clear_scheduled_hook( 'wp_cache_check_site_hook' );
|
158 |
wp_clear_scheduled_hook( 'wp_cache_gc' );
|
159 |
wp_clear_scheduled_hook( 'wp_cache_gc_watcher' );
|
216 |
function wp_cache_manager_error_checks() {
|
217 |
global $wp_cache_debug, $wp_cache_cron_check, $cache_enabled, $super_cache_enabled, $wp_cache_config_file, $wp_cache_mobile_browsers, $wp_cache_mobile_prefixes, $wp_cache_mobile_browsers, $wp_cache_mobile_enabled, $wp_cache_mod_rewrite;
|
218 |
global $dismiss_htaccess_warning, $dismiss_readable_warning, $dismiss_gc_warning, $wp_cache_shutdown_gc, $is_nginx;
|
219 |
+
global $htaccess_path;
|
220 |
|
221 |
if ( !wpsupercache_site_admin() )
|
222 |
return false;
|
285 |
if ( false == function_exists( 'wpsc_deep_replace' ) ) {
|
286 |
$msg = __( 'Warning! You must set WP_CACHE and WPCACHEHOME in your wp-config.php for this plugin to work correctly:' ) . '<br />';
|
287 |
$msg .= "<code>define( 'WP_CACHE', true );</code><br />";
|
288 |
+
$msg .= "<code>define( 'WPCACHEHOME', '" . dirname( __FILE__ ) . "/' );</code><br />";
|
289 |
wp_die( $msg );
|
290 |
}
|
291 |
|
378 |
}
|
379 |
|
380 |
if ( ! $is_nginx && function_exists( "is_main_site" ) && true == is_main_site() ) {
|
381 |
+
if ( isset( $htaccess_path ) ) {
|
382 |
+
$home_path = trailingslashit( get_home_path() );
|
383 |
+
} else {
|
384 |
+
$home_path = $htaccess_path;
|
385 |
+
}
|
386 |
$scrules = implode( "\n", extract_from_markers( $home_path.'.htaccess', 'WPSuperCache' ) );
|
387 |
if ( $cache_enabled && $wp_cache_mod_rewrite && !$wp_cache_mobile_enabled && strpos( $scrules, addcslashes( str_replace( ', ', '|', $wp_cache_mobile_browsers ), ' ' ) ) ) {
|
388 |
echo '<div class="notice notice-warning"><h3>' . __( 'Mobile rewrite rules detected', 'wp-super-cache' ) . "</h3>";
|
742 |
} elseif ( function_exists( 'lite_detection_ua_contains' ) ) {
|
743 |
$wp_cache_mobile_browsers = explode( '|', lite_detection_ua_contains() );
|
744 |
} else {
|
745 |
+
$wp_cache_mobile_browsers = array( '2.0 MMP', '240x320', '400X240', 'AvantGo', 'BlackBerry', 'Blazer', 'Cellphone', 'Danger', 'DoCoMo', 'Elaine/3.0', 'EudoraWeb', 'Googlebot-Mobile', 'hiptop', 'IEMobile', 'KYOCERA/WX310K', 'LG/U990', 'MIDP-2.', 'MMEF20', 'MOT-V', 'NetFront', 'Newt', 'Nintendo Wii', 'Nitro', 'Nokia', 'Opera Mini', 'Palm', 'PlayStation Portable', 'portalmmm', 'Proxinet', 'ProxiNet', 'SHARP-TQ-GX10', 'SHG-i900', 'Small', 'SonyEricsson', 'Symbian OS', 'SymbianOS', 'TS21i-10', 'UP.Browser', 'UP.Link', 'webOS', 'Windows CE', 'WinWAP', 'YahooSeeker/M1A1-R2D2', 'iPhone', 'iPod', 'iPad', 'Android', 'BlackBerry9530', 'LG-TU915 Obigo', 'LGE VX', 'webOS', 'Nokia5800' );
|
746 |
}
|
747 |
if ( function_exists( "lite_detection_ua_prefixes" ) ) {
|
748 |
$wp_cache_mobile_prefixes = lite_detection_ua_prefixes();
|
1273 |
<p><?php _e( 'Caching is only one part of making a website faster. Here are some other plugins that will help:', 'wp-super-cache' ); ?></p>
|
1274 |
<ul style="list-style: square; margin-left: 2em;">
|
1275 |
<li><?php printf( __( '<a href="%s">Jetpack</a> provides everything you need to build a successful WordPress website including an image/photo CDN (free) and a video hosting service (paid).', 'wp-super-cache' ), 'https://jetpack.com/redirect/?source=jitm-wpsc-recommended' ); ?></li>
|
1276 |
+
<li><?php printf( __( '<a href="%s">Yahoo! Yslow</a> analyzes web pages and suggests ways to improve their performance based on a set of rules for high performance web pages. Also try the performance tools online at <a href="%s">GTMetrix</a>.', 'wp-super-cache' ), 'http://yslow.org/', 'https://gtmetrix.com/' ); ?></li>
|
1277 |
<li><?php printf( __( '<a href="%s">Use Google Libraries</a> allows you to load some commonly used Javascript libraries from Google webservers. Ironically, it may reduce your Yslow score.', 'wp-super-cache' ), 'https://wordpress.org/plugins/use-google-libraries/' ); ?></li>
|
1278 |
<li><?php printf( __( '<strong>Advanced users only:</strong> Install an object cache. Choose from <a href="%s">Memcached</a>, <a href="%s">XCache</a>, <a href="%s">eAcccelerator</a> and others.', 'wp-super-cache' ), 'https://wordpress.org/plugins/memcached/', 'https://neosmart.net/WP/XCache/', 'https://neosmart.net/WP/eAccelerator/' ); ?></li>
|
1279 |
+
<li><?php printf( __( '<a href="%s">WP Control</a> is a useful plugin to use when trying to debug garbage collection and preload problems.', 'wp-super-cache' ), 'https://wordpress.org/plugins/wp-crontrol/' ); ?></li>
|
1280 |
</ul>
|
1281 |
|
1282 |
<?php
|
1381 |
}
|
1382 |
|
1383 |
function wsc_mod_rewrite() {
|
1384 |
+
global $valid_nonce, $cache_path;
|
1385 |
|
1386 |
+
if ( $GLOBALS['is_nginx'] ) {
|
1387 |
return false;
|
1388 |
}
|
1389 |
|
1390 |
+
if ( defined( 'WPSC_DISABLE_HTACCESS_UPDATE' ) ) {
|
1391 |
return false;
|
1392 |
+
}
|
1393 |
|
1394 |
+
if ( $GLOBALS['cache_enabled'] !== true || $GLOBALS['wp_cache_mod_rewrite'] !== 1 ) {
|
1395 |
return false;
|
1396 |
+
}
|
1397 |
+
|
1398 |
?>
|
1399 |
<a name="modrewrite"></a><fieldset class="options">
|
1400 |
<h3><?php _e( 'Mod Rewrite Rules', 'wp-super-cache' ); ?></h3>
|
1994 |
);
|
1995 |
}
|
1996 |
|
1997 |
+
if ( isset( $_POST[ 'wpsc_delete_log' ] ) && $_POST[ 'wpsc_delete_log' ] == 1 && $wp_cache_debug_log != '' ) {
|
1998 |
@unlink( $cache_path . $wp_cache_debug_log );
|
1999 |
extract( wpsc_create_debug_log( $wp_cache_debug_log, $wp_cache_debug_username ) ); // $wp_cache_debug_log, $wp_cache_debug_username
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2000 |
}
|
2001 |
|
2002 |
+
if ( ! isset( $wp_cache_debug_log ) || $wp_cache_debug_log == '' ) {
|
2003 |
+
extract( wpsc_create_debug_log() ); // $wp_cache_debug_log, $wp_cache_debug_username
|
2004 |
+
} elseif ( ! file_exists( $cache_path . $wp_cache_debug_log ) ) { // make sure debug log exists before toggling debugging
|
2005 |
+
extract( wpsc_create_debug_log( $wp_cache_debug_log, $wp_cache_debug_username ) ); // $wp_cache_debug_log, $wp_cache_debug_username
|
2006 |
+
}
|
2007 |
+
$wp_super_cache_debug = ( isset( $_POST[ 'wp_super_cache_debug' ] ) && $_POST[ 'wp_super_cache_debug' ] == 1 ) ? 1 : 0;
|
2008 |
+
wp_cache_setting( 'wp_super_cache_debug', $wp_super_cache_debug );
|
2009 |
+
|
2010 |
if ( isset( $_POST[ 'wp_cache_debug' ] ) ) {
|
2011 |
wp_cache_setting( 'wp_cache_debug_username', $wp_cache_debug_username );
|
2012 |
wp_cache_setting( 'wp_cache_debug_log', $wp_cache_debug_log );
|
2013 |
$wp_super_cache_comments = isset( $_POST[ 'wp_super_cache_comments' ] ) ? 1 : 0;
|
2014 |
wp_cache_setting( 'wp_super_cache_comments', $wp_super_cache_comments );
|
2015 |
+
if ( isset( $_POST[ 'wp_cache_debug_ip' ] ) ) {
|
2016 |
+
$wp_cache_debug_ip = esc_html( $_POST[ 'wp_cache_debug_ip' ] );
|
2017 |
+
} else {
|
2018 |
+
$wp_cache_debug_ip = '';
|
2019 |
+
}
|
2020 |
wp_cache_setting( 'wp_cache_debug_ip', $wp_cache_debug_ip );
|
2021 |
$wp_super_cache_front_page_check = isset( $_POST[ 'wp_super_cache_front_page_check' ] ) ? 1 : 0;
|
2022 |
wp_cache_setting( 'wp_super_cache_front_page_check', $wp_super_cache_front_page_check );
|
2023 |
$wp_super_cache_front_page_clear = isset( $_POST[ 'wp_super_cache_front_page_clear' ] ) ? 1 : 0;
|
2024 |
wp_cache_setting( 'wp_super_cache_front_page_clear', $wp_super_cache_front_page_clear );
|
2025 |
+
if ( isset( $_POST[ 'wp_super_cache_front_page_text' ] ) ) {
|
2026 |
+
$wp_super_cache_front_page_text = esc_html( $_POST[ 'wp_super_cache_front_page_text' ] );
|
2027 |
+
} else {
|
2028 |
+
$wp_super_cache_front_page_text = '';
|
2029 |
+
}
|
2030 |
wp_cache_setting( 'wp_super_cache_front_page_text', $wp_super_cache_front_page_text );
|
2031 |
$wp_super_cache_front_page_notification = isset( $_POST[ 'wp_super_cache_front_page_notification' ] ) ? 1 : 0;
|
2032 |
wp_cache_setting( 'wp_super_cache_front_page_notification', $wp_super_cache_front_page_notification );
|
2074 |
|
2075 |
echo '<form name="wpsc_delete" action="" method="post">';
|
2076 |
wp_nonce_field('wp-cache');
|
2077 |
+
echo "<input type='hidden' name='wpsc_delete_log' value='1' />";
|
2078 |
+
submit_button( __( 'Delete', 'wp-super-cache' ), 'delete', 'wpsc_delete_log_form', false );
|
2079 |
echo "</form>";
|
2080 |
echo '<form name="wpsc_delete" action="" method="post">';
|
2081 |
if ( ! isset( $wp_super_cache_debug ) || $wp_super_cache_debug == 0 ) {
|
2119 |
function wp_cache_enable() {
|
2120 |
global $wp_cache_config_file, $cache_enabled;
|
2121 |
|
2122 |
+
if ( ! wp_cache_replace_line( '^\s*\$cache_enabled\s*=', '$cache_enabled = true;', $wp_cache_config_file ) ) {
|
2123 |
+
return;
|
2124 |
}
|
2125 |
|
2126 |
+
$cache_enabled = true;
|
2127 |
+
|
2128 |
if ( wpsc_set_default_gc() ) {
|
2129 |
// gc might not be scheduled, check and schedule
|
2130 |
$timestamp = wp_next_scheduled( 'wp_cache_gc' );
|
2137 |
function wp_cache_disable() {
|
2138 |
global $wp_cache_config_file, $cache_enabled;
|
2139 |
|
2140 |
+
if ( ! wp_cache_replace_line( '^\s*\$cache_enabled\s*=', '$cache_enabled = false;', $wp_cache_config_file ) ) {
|
2141 |
+
return;
|
2142 |
+
}
|
2143 |
+
|
2144 |
+
$cache_enabled = false;
|
2145 |
+
|
2146 |
wp_clear_scheduled_hook( 'wp_cache_check_site_hook' );
|
2147 |
wp_clear_scheduled_hook( 'wp_cache_gc' );
|
2148 |
wp_clear_scheduled_hook( 'wp_cache_gc_watcher' );
|
|
|
|
|
|
|
2149 |
}
|
2150 |
+
|
2151 |
function wp_super_cache_enable() {
|
2152 |
global $supercachedir, $wp_cache_config_file, $super_cache_enabled;
|
2153 |
|
2154 |
+
if ( ! wp_cache_replace_line( '^\s*\$super_cache_enabled\s*=', '$super_cache_enabled = true;', $wp_cache_config_file ) ) {
|
2155 |
+
return;
|
2156 |
+
}
|
2157 |
+
|
2158 |
+
$super_cache_enabled = true;
|
2159 |
+
|
2160 |
+
if ( is_dir( $supercachedir . '.disabled' ) ) {
|
2161 |
+
if ( is_dir( $supercachedir ) ) {
|
2162 |
+
prune_super_cache( $supercachedir . '.disabled', true );
|
2163 |
+
@unlink( $supercachedir . '.disabled' );
|
2164 |
} else {
|
2165 |
+
@rename( $supercachedir . '.disabled', $supercachedir );
|
2166 |
}
|
2167 |
+
}
|
|
|
2168 |
}
|
2169 |
|
2170 |
function wp_super_cache_disable() {
|
2171 |
global $cache_path, $supercachedir, $wp_cache_config_file, $super_cache_enabled;
|
2172 |
|
2173 |
+
if ( ! wp_cache_replace_line('^\s*\$super_cache_enabled\s*=', '$super_cache_enabled = false;', $wp_cache_config_file ) ) {
|
2174 |
+
return;
|
2175 |
+
}
|
2176 |
+
|
2177 |
$super_cache_enabled = false;
|
2178 |
+
|
2179 |
+
if ( is_dir( $supercachedir ) ) {
|
2180 |
+
@rename( $supercachedir, $supercachedir . '.disabled' );
|
2181 |
+
}
|
2182 |
sleep( 1 ); // allow existing processes to write to the supercachedir and then delete it
|
2183 |
+
if ( function_exists( 'prune_super_cache' ) && is_dir( $supercachedir ) ) {
|
2184 |
prune_super_cache( $cache_path, true );
|
2185 |
}
|
2186 |
+
|
2187 |
+
if ( $GLOBALS['wp_cache_mod_rewrite'] === 1 ) {
|
2188 |
+
remove_mod_rewrite_rules();
|
2189 |
+
}
|
2190 |
}
|
2191 |
|
2192 |
function wp_cache_is_enabled() {
|
2193 |
global $wp_cache_config_file;
|
2194 |
|
2195 |
+
if ( get_option( 'gzipcompression' ) ) {
|
2196 |
+
echo '<strong>' . __( 'Warning', 'wp-super-cache' ) . '</strong>: ' . __( 'GZIP compression is enabled in WordPress, wp-cache will be bypassed until you disable gzip compression.', 'wp-super-cache' );
|
2197 |
return false;
|
2198 |
}
|
2199 |
+
|
2200 |
+
$lines = file( $wp_cache_config_file );
|
2201 |
+
foreach ( $lines as $line ) {
|
2202 |
+
if ( preg_match( '/^\s*\$cache_enabled\s*=\s*true\s*;/', $line ) ) {
|
2203 |
return true;
|
2204 |
+
}
|
2205 |
}
|
2206 |
+
|
2207 |
return false;
|
2208 |
}
|
2209 |
|
2210 |
function wp_cache_remove_index() {
|
2211 |
global $cache_path;
|
2212 |
|
2213 |
+
if ( empty( $cache_path ) ) {
|
2214 |
return;
|
2215 |
}
|
2216 |
|
2324 |
add_site_option( 'wp_super_cache_index_detected', 1 ); // only show this once
|
2325 |
}
|
2326 |
}
|
2327 |
+
if ( ! function_exists( 'insert_with_markers' ) ) {
|
2328 |
+
include_once( ABSPATH . 'wp-admin/includes/misc.php' );
|
2329 |
+
}
|
2330 |
insert_with_markers( $cache_path . '.htaccess', "INDEX", array( 'Options -Indexes' ) );
|
2331 |
}
|
2332 |
|
2889 |
function wp_cache_clean_cache( $file_prefix, $all = false ) {
|
2890 |
global $cache_path, $supercachedir, $blog_cache_dir, $wp_cache_object_cache;
|
2891 |
|
2892 |
+
do_action( 'wp_cache_cleared' );
|
2893 |
+
|
2894 |
if ( $wp_cache_object_cache && function_exists( "reset_oc_version" ) )
|
2895 |
reset_oc_version();
|
2896 |
|
3199 |
|
3200 |
function wpsc_get_htaccess_info() {
|
3201 |
global $wp_cache_mobile_enabled, $wp_cache_mobile_prefixes, $wp_cache_mobile_browsers, $wp_cache_disable_utf8;
|
3202 |
+
global $htaccess_path;
|
3203 |
+
|
3204 |
if ( isset( $_SERVER[ "PHP_DOCUMENT_ROOT" ] ) ) {
|
3205 |
$document_root = $_SERVER[ "PHP_DOCUMENT_ROOT" ];
|
3206 |
$apache_root = $_SERVER[ "PHP_DOCUMENT_ROOT" ];
|
3229 |
$home_path = get_home_path();
|
3230 |
$home_root = parse_url(get_bloginfo('url'));
|
3231 |
$home_root = isset( $home_root[ 'path' ] ) ? trailingslashit( $home_root[ 'path' ] ) : '/';
|
3232 |
+
if ( isset( $htaccess_path ) ) {
|
3233 |
+
$home_path = $htaccess_path;
|
3234 |
+
} elseif (
|
3235 |
$home_root == '/' &&
|
3236 |
$home_path != $_SERVER[ 'DOCUMENT_ROOT' ]
|
3237 |
) {
|
3257 |
$condition_rules[] = "RewriteCond %{REQUEST_URI} !^.*//.*$";
|
3258 |
}
|
3259 |
$condition_rules[] = "RewriteCond %{REQUEST_METHOD} !POST";
|
3260 |
+
$condition_rules[] = "RewriteCond %{QUERY_STRING} ^$";
|
3261 |
$condition_rules[] = "RewriteCond %{HTTP:Cookie} !^.*(comment_author_|" . wpsc_get_logged_in_cookie() . "|wp-postpass_).*$";
|
3262 |
$condition_rules[] = "RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\\\"]+ [NC]";
|
3263 |
$condition_rules[] = "RewriteCond %{HTTP:Profile} !^[a-z0-9\\\"]+ [NC]";
|
3330 |
|
3331 |
if ( get_option( 'preload_cache_stop' ) ) {
|
3332 |
delete_option( 'preload_cache_stop' );
|
3333 |
+
wp_cache_debug( 'wp_cron_preload_cache: preload cancelled', 1 );
|
3334 |
return true;
|
3335 |
}
|
3336 |
|
3338 |
sleep( 3 + mt_rand( 1, 5 ) );
|
3339 |
if ( @file_exists( $mutex ) ) {
|
3340 |
if ( @filemtime( $mutex ) > ( time() - 600 ) ) {
|
3341 |
+
wp_cache_debug( 'wp_cron_preload_cache: preload mutex found and less than 600 seconds old. Aborting preload.', 1 );
|
3342 |
return true;
|
3343 |
} else {
|
3344 |
+
wp_cache_debug( 'wp_cron_preload_cache: old preload mutex found and deleted. Preload continues.', 1 );
|
3345 |
@unlink( $mutex );
|
3346 |
}
|
3347 |
}
|
3350 |
|
3351 |
$counter = get_option( 'preload_cache_counter' );
|
3352 |
if ( is_array( $counter ) == false ) {
|
3353 |
+
wp_cache_debug( 'wp_cron_preload_cache: setting up preload for the first time!', 5 );
|
3354 |
$counter = array( 'c' => 0, 't' => time() );
|
3355 |
update_option( 'preload_cache_counter', $counter );
|
3356 |
}
|
3366 |
wp_mail( get_option( 'admin_email' ), sprintf( __( '[%1$s] Cache Preload Started', 'wp-super-cache' ), home_url(), '' ), ' ' );
|
3367 |
|
3368 |
if ( $wp_cache_preload_posts == 'all' || $c < $wp_cache_preload_posts ) {
|
3369 |
+
wp_cache_debug( 'wp_cron_preload_cache: doing taxonomy preload.', 5 );
|
3370 |
$permalink_counter_msg = $cache_path . "preload_permalink.txt";
|
3371 |
if ( isset( $wp_cache_preload_taxonomies ) && $wp_cache_preload_taxonomies ) {
|
3372 |
$taxonomies = apply_filters( 'wp_cache_preload_taxonomies', array( 'post_tag' => 'tag', 'category' => 'category' ) );
|
3411 |
wp_cache_debug( "wp_cron_preload_cache: fetched $url", 5 );
|
3412 |
sleep( 1 );
|
3413 |
if ( @file_exists( $cache_path . "stop_preload.txt" ) ) {
|
3414 |
+
wp_cache_debug( 'wp_cron_preload_cache: cancelling preload. stop_preload.txt found.', 5 );
|
3415 |
@unlink( $mutex );
|
3416 |
@unlink( $cache_path . "stop_preload.txt" );
|
3417 |
@unlink( $taxonomy_filename );
|
3471 |
@fclose( $fp );
|
3472 |
}
|
3473 |
if ( @file_exists( $cache_path . "stop_preload.txt" ) ) {
|
3474 |
+
wp_cache_debug( 'wp_cron_preload_cache: cancelling preload. stop_preload.txt found.', 5 );
|
3475 |
@unlink( $mutex );
|
3476 |
@unlink( $cache_path . "stop_preload.txt" );
|
3477 |
update_option( 'preload_cache_counter', array( 'c' => 0, 't' => time() ) );
|
3488 |
if ( $wp_cache_preload_email_me && ( $wp_cache_preload_email_volume == 'medium' || $wp_cache_preload_email_volume == 'many' ) )
|
3489 |
wp_mail( get_option( 'admin_email' ), sprintf( __( '[%1$s] %2$d posts refreshed', 'wp-super-cache' ), home_url(), ($c+100) ), __( "Refreshed the following posts:", 'wp-super-cache' ) . "\n$msg" );
|
3490 |
if ( defined( 'DOING_CRON' ) ) {
|
3491 |
+
wp_cache_debug( 'wp_cron_preload_cache: scheduling the next preload in 30 seconds.', 5 );
|
3492 |
wp_schedule_single_event( time() + 30, 'wp_cache_preload_hook' );
|
3493 |
}
|
3494 |
} else {
|
3880 |
}
|
3881 |
|
3882 |
$generated_rules = wpsc_get_htaccess_info();
|
3883 |
+
$existing_rules = implode( "\n", extract_from_markers( $home_path . '.htaccess', 'WPSuperCache' ) );
|
3884 |
|
3885 |
+
$rules = $add_rules ? $generated_rules[ 'rules' ] : '';
|
|
|
|
|
|
|
|
|
|
|
|
|
3886 |
|
3887 |
if ( $existing_rules == $rules ) {
|
3888 |
$update_mod_rewrite_rules_error = "rules have not changed";
|
3894 |
return false;
|
3895 |
}
|
3896 |
|
3897 |
+
if ( empty( $rules ) ) {
|
3898 |
+
return insert_with_markers( $home_path . '.htaccess', 'WPSuperCache', array() );
|
3899 |
+
}
|
3900 |
+
|
3901 |
$url = trailingslashit( get_bloginfo( 'url' ) );
|
3902 |
$original_page = wp_remote_get( $url, array( 'timeout' => 60, 'blocking' => true ) );
|
3903 |
if ( is_wp_error( $original_page ) ) {
|