WP Super Cache - Version 1.4.3

Version Description

Security release fixing an XSS bug in the settings page.

=

Download this release

Release Info

Developer donncha
Plugin Icon 128x128 WP Super Cache
Version 1.4.3
Comparing to
See all releases

Code changes from version 1.4.2 to 1.4.3

Changelog.txt CHANGED
@@ -1,3 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  2014-08-08 13:07 donncha
2
 
3
  * wp-cache-phase1.php: Just in case the local modified time of a
@@ -101,181 +153,93 @@
101
  * wp-cache-phase2.php: Make sure these are global so the function
102
  knows about them. Props JoHenton and richardmtl
103
  http://wordpress.org/support/topic/notices-appearing-above-site-pages-how-do-i-get-rid-of-them?replies=2
104
- 2013-10-23 10:49 donncha
105
-
106
- * wp-super-cache.pot: Updated translation file
107
-
108
- 2013-10-23 10:35 donncha
109
-
110
- * readme.txt: Updated changelog
111
-
112
- 2013-10-22 20:26 donncha
113
-
114
- * wp-cache-phase1.php, wp-cache.php: Handle site migration more
115
- gracefully. Recreate advanced-cache.php and WPCACHEHOME if
116
- wp-cache-phase1.php wasn't loaded when admin loaded.
117
-
118
- 2013-10-22 20:24 donncha
119
-
120
- * wp-cache-phase2.php: Minor change to text of buffer warning when
121
- late init not set on dynamic pages
122
-
123
- 2013-10-22 12:06 donncha
124
-
125
- * wp-cache-phase2.php: No assign by reference here, not allowed any
126
- more. Ref:
127
- http://wordpress.org/support/topic/php-strict-standards-2?replies=1
128
-
129
- 2013-10-22 11:58 donncha
130
-
131
- * Changelog.txt: Updated and truncated Changelog. It was getting
132
- way too big
133
-
134
- 2013-10-22 11:52 donncha
135
-
136
- * readme.txt: Updated docs, mostly in the dynamic content section
137
-
138
- 2013-10-21 14:23 donncha
139
-
140
- * wp-cache-phase2.php: Added debug log when obsolete mfunc tags
141
- used
142
-
143
- 2013-10-21 14:13 donncha
144
-
145
- * plugins/dynamic-cache-test.php: Added and output buffer example
146
- plugin
147
-
148
- 2013-10-21 14:02 donncha
149
-
150
- * wp-cache-phase2.php: Added "wpsc_cachedata_safety" filter to
151
- allow plugins to make sure they're ready to run filter.
152
-
153
- 2013-10-18 16:44 donncha
154
-
155
- * wp-cache-phase2.php: Revert the code that would allow output
156
- buffer callbacks to work in dynamic cached pages. It's too
157
- complicated/dangerous for too little payback. See
158
- http://wordpress.org/support/topic/mfunc-is-going-away-in-the-next-version
159
-
160
- 2013-08-20 13:13 donncha
161
-
162
- * wp-cache-phase2.php: Use a function hooked on to the shutdown
163
- action to display the buffer for dynamic cached blogs. See
164
- http://wordpress.org/support/topic/mfunc-is-going-away-in-the-next-version
165
-
166
- 2013-08-19 20:16 donncha
167
-
168
- * readme.txt: Bumped version to 3.6
169
-
170
- 2013-08-02 21:07 donncha
171
-
172
- * wp-cache.php: Added check for constant
173
- "WPSC_DISABLE_HTACCESS_UPDATE" to disable updating the .htaccess
174
- rules. Ref:
175
- http://wordpress.org/support/topic/cache-control-max-age3-must-revalidate?replies=1
176
-
177
- 2013-08-02 20:57 donncha
178
-
179
- * wp-cache-phase2.php: Added function "wpsc_post_transition" that
180
- deletes the post, tag and category cache when a post changes from
181
- draft to publish or publish to draft. Props @Biranit
182
- http://wordpress.org/support/topic/wp-super-cache-do-not-delete-category-pages-when-new-post-is-posted?replies=8#post-4467574
183
-
184
- 2013-07-04 16:01 donncha
185
-
186
- * readme.txt: The next version will be 1.4, update the versions in
187
- the changelog
188
-
189
- 2013-07-04 15:52 donncha
190
-
191
- * readme.txt: Updated the FAQ
192
-
193
- 2013-07-04 15:26 donncha
194
-
195
- * wp-cache-phase2.php: Detect old mfunc tags and add a warning in
196
- the source of the page.
197
-
198
- 2013-07-04 13:47 donncha
199
 
200
- * wp-cache-phase2.php: * Return a buffer directly and maybe reduce
201
- memory usage.
202
- * Minor text changes
203
 
204
- 2013-07-04 13:44 donncha
205
 
206
- * plugins/searchengine.php: Avoid warnings in the php logs
207
 
208
- 2013-05-20 12:35 donncha
 
209
 
210
- * languages/wp-super-cache-sr_RS.mo,
211
- languages/wp-super-cache-sr_RS.po, readme.txt: Added
212
- Serbo-Croatian translation by Anja Skrba
213
 
214
- 2013-05-20 12:32 donncha
 
215
 
216
- * readme.txt: Updated dynamic cache content FAQ and added new FAQ
217
- on plugins & upgrading
218
 
219
- 2013-05-09 13:46 donncha
 
 
220
 
221
- * readme.txt: Updated changelog
222
 
223
- 2013-05-01 12:34 donncha
 
 
224
 
225
- * plugins/dynamic-cache-test.php: Added "DYNAMIC_CACHE_TEST_TAG"
226
- constant so users will have to pick a secret template tag
227
 
228
- 2013-05-01 12:19 donncha
 
 
 
229
 
230
- * wp-cache-phase2.php: Make sure we process the wpsc_cachedata
231
- cache action even when the page isn't being cached for known
232
- users.
233
 
234
- 2013-04-26 13:10 donncha
 
235
 
236
- * wp-cache-phase2.php: Always set the dynamic flag in the meta
237
- headers for legacy caching when it's required.
238
 
239
- 2013-04-26 11:51 donncha
 
240
 
241
- * wp-cache.php: Dynamic caching option requires legacy or php mode.
242
- Fixed and improved text explanation.
243
 
244
- 2013-04-26 11:48 donncha
245
 
246
- * wp-cache.php: No need for this function that removes mfunc from
247
- comments when mfunc isn't used any more
248
 
249
- 2013-04-25 20:44 donncha
 
 
250
 
251
- * wp-cache-phase1.php: Files should not be compressed when
252
- compression is turned off!
253
 
254
- 2013-04-25 16:36 donncha
 
 
255
 
256
- * plugins/dynamic-cache-test.php: Added example dynamic cache
257
- script
258
 
259
- 2013-04-25 16:00 donncha
 
 
 
260
 
261
- * wp-cache-phase1.php, wp-cache-phase2.php: Replace legacy
262
- mfunc/mnclude/dynamic-cached-data functionality with a
263
- "wpsc_cachedata" cacheaction filter
264
 
265
- 2013-04-25 11:11 donncha
 
266
 
267
- * wp-cache-phase2.php: Fix some warning during import, props David
268
- Lowry, https://twitter.com/djlowry/status/327369568286826496
269
 
270
- 2013-04-24 19:57 donncha
 
 
271
 
272
- * Changelog.txt: Updated changelog
273
 
274
- 2013-04-24 19:53 donncha
 
 
275
 
276
- * readme.txt, wp-cache.php: Bump version to 1.3.2
277
 
278
- 2013-04-24 19:52 donncha
 
279
 
280
- * readme.txt: Added upgrade notice and changelog for 1.3.2
281
 
1
+ 2015-04-03 16:44 donncha
2
+
3
+ * readme.txt, wp-cache.php: Bump version to 1.4.3, update
4
+ changelog, and add link to GIT repo.
5
+
6
+ 2015-04-03 15:37 donncha
7
+
8
+ * wp-cache.php: Escape the contents of the cache list to avoid
9
+ surprises. Props Marc Montpas from Sucuri.
10
+
11
+ 2014-12-18 10:55 jeherve
12
+
13
+ * readme.txt: Bump testing to 4.1
14
+
15
+ 2014-10-10 14:07 kraftbj
16
+
17
+ * plugins/jetpack.php, wp-cache-phase1.php, wp-cache-phase2.php,
18
+ wp-cache.php: Removing variable checks since wp_cache_debug does
19
+ it already. Ref:
20
+ https://github.com/Automattic/wp-super-cache/pull/15
21
+
22
+ 2014-10-10 14:06 kraftbj
23
+
24
+ * readme.txt: Catch up to SVN
25
+
26
+ 2014-10-10 14:06 kraftbj
27
+
28
+ * readme.txt: Add Jetpack to mobile FAQ.
29
+
30
+ 2014-09-04 14:16 kraftbj
31
+
32
+ * readme.txt: Bumped testing to 4.0
33
+
34
+ 2014-08-11 19:06 donncha
35
+
36
+ * plugins/dynamic-cache-test.php: Because without a h we'd have
37
+ time keeping. Fixed a typo.
38
+
39
+ 2014-08-11 18:44 donncha
40
+
41
+ * plugins/dynamic-cache-test.php: Added cronology of a request
42
+
43
+ 2014-08-11 18:22 donncha
44
+
45
+ * plugins/dynamic-cache-test.php: Fixed the safety function in the
46
+ first example test function
47
+
48
+ 2014-08-08 16:27 donncha
49
+
50
+ * Changelog.txt, readme.txt, wp-cache.php: Bump version to 1.4.2
51
+ and update changelog
52
+
53
  2014-08-08 13:07 donncha
54
 
55
  * wp-cache-phase1.php: Just in case the local modified time of a
153
  * wp-cache-phase2.php: Make sure these are global so the function
154
  knows about them. Props JoHenton and richardmtl
155
  http://wordpress.org/support/topic/notices-appearing-above-site-pages-how-do-i-get-rid-of-them?replies=2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
 
157
+ 2014-04-17 16:21 donncha
 
 
158
 
159
+ * readme.txt: Bump tested version to 3.9
160
 
161
+ 2014-03-11 17:58 donncha
162
 
163
+ * wp-cache.php: Fix undefined variables warnings. Ref:
164
+ http://wordpress.org/support/topic/plugin-wp-super-cache-lot-of-undefined-variables-and-couple-of-warnings?replies=4
165
 
166
+ 2014-03-07 18:00 donncha
 
 
167
 
168
+ * plugins/dynamic-cache-test.php: Better comments and rearrange
169
+ example scripts
170
 
171
+ 2014-03-05 12:37 donncha
 
172
 
173
+ * wp-cache-phase1.php: HTTP_IF_MODIFIED_SINCE isn't always defined,
174
+ so check first.
175
+ http://wordpress.org/support/topic/undefined-index-http_if_modified_since?replies=1
176
 
177
+ 2014-03-05 11:54 donncha
178
 
179
+ * wp-cache-phase1.php, wp-cache-phase2.php: Don't check "do not
180
+ cache" conditions until after page buffer has been filled. Ref:
181
+ http://wordpress.org/support/topic/bug-dynamic-cache-tags-are-not-replaced-because-of-wp_cache_phase2-conditions
182
 
183
+ 2014-03-04 17:26 donncha
 
184
 
185
+ * wp-cache-phase2.php: Added the function wp_cache_maybe_dynamic()
186
+ to run buffer through the dynamic cache filter if callback
187
+ returned early. Ref:
188
+ http://wordpress.org/support/topic/bug-dynamic-cache-tags-are-not-replaced-because-of-wp_cache_phase2-conditions?replies=1
189
 
190
+ 2014-03-04 16:27 donncha
 
 
191
 
192
+ * wp-cache-phase1.php: Hide any warnings from this opendir() as it
193
+ somehow fails occasionally.
194
 
195
+ 2014-02-25 17:48 donncha
 
196
 
197
+ * wp-cache.php: Clear the cache for the current blog only, don't
198
+ want to mess with other multisite blogs
199
 
200
+ 2014-02-25 16:24 donncha
 
201
 
202
+ * readme.txt: Bump tested version to current WP version
203
 
204
+ 2013-11-29 15:34 donncha
 
205
 
206
+ * wp-cache-phase2.php: Check that $post is an object as this
207
+ function is used for more than just post changes.
208
+ http://wordpress.org/support/topic/error-switching-themes?replies=2
209
 
210
+ 2013-11-12 09:55 donncha
 
211
 
212
+ * advanced-cache.php: Don't show the "advanced-cache.php warning"
213
+ when the plugin isn't loaded, props RobertHarm,
214
+ http://wordpress.org/support/topic/wp-super-cache-breaks-leaflet-maps-marker-plugin
215
 
216
+ 2013-10-25 14:37 donncha
 
217
 
218
+ * wp-cache.php: Define $disable_supercache_htaccess_warning if not
219
+ set to avoid PHP warnings, ref:
220
+ http://wordpress.org/support/topic/just-a-few-notices-non-critical?replies=1,
221
+ props @mattV
222
 
223
+ 2013-10-25 14:33 donncha
 
 
224
 
225
+ * wp-cache-base.php: Avoid a PHP warning if $base is not set. Ref:
226
+ http://wordpress.org/support/topic/just-a-few-notices-non-critical?replies=1
227
 
228
+ 2013-10-25 09:29 donncha
 
229
 
230
+ * wp-cache.php: Only display the WPCACHEHOME warning if WP_CACHE is
231
+ defined and true. Warning won't show until settings page loaded
232
+ that WP_CACHE added to wp-config.php
233
 
234
+ 2013-10-24 11:23 donncha
235
 
236
+ * wp-cache.php: Add trailing slashes to the admin bar path, to fix
237
+ the path when no trailing slash is used. Props @gonperesgmailcom
238
+ http://wordpress.org/support/topic/fixed-delete-individual-pages-from-cache?replies=2
239
 
240
+ 2013-10-23 10:56 donncha
241
 
242
+ * readme.txt, wp-cache.php: Bump version to 1.4 and tested version
243
+ to 3.6.1
244
 
 
245
 
plugins/dynamic-cache-test.php CHANGED
@@ -54,14 +54,27 @@
54
  * the cached page this time will change. View the page source to examine
55
  * this text.
56
  *
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  */
58
  define( 'DYNAMIC_CACHE_TEST_TAG', '' ); // Change this to a secret placeholder tag
59
  if ( DYNAMIC_CACHE_TEST_TAG != '' ) {
60
  function dynamic_cache_test_safety( $safety ) {
61
  return 1;
62
  }
63
- add_cacheaction( 'wpsc_cachedata_safety', 'dynamic_output_buffer_test_safety' );
64
-
65
 
66
  function dynamic_cache_test_filter( &$cachedata) {
67
  return str_replace( DYNAMIC_CACHE_TEST_TAG, "<!-- Hello world at " . date( 'H:i:s' ) . " -->", $cachedata );
54
  * the cached page this time will change. View the page source to examine
55
  * this text.
56
  *
57
+ * Chronology of a request:
58
+ * 1. dynamic_cache_test_init() hooks dynamic_cache_test_template_tag() on
59
+ * to the wp_footer action. dynamic_cache_test_filter() is hooked on to
60
+ * the wpsc_cachedata filter.
61
+ * 2. An output buffer is created by WP Super Cache.
62
+ * 3. Most of the page is generated by WordPress.
63
+ * 4. The wp_footer action fires and the TAG is printed to the page.
64
+ * 5. Processing continues and the page is created.
65
+ * 6. The output buffer finishes. A WP Super Cache callback function runs
66
+ * and saves the output buffer to a cache file. The wpsc_cachedata
67
+ * filter is called.
68
+ * 7. The function dynamic_cache_test_filter() runs and replaces the TAG in
69
+ * the buffer with the "Hello world" string.
70
+ * 8. The output buffer is pushed to the browser to be displayed.
71
  */
72
  define( 'DYNAMIC_CACHE_TEST_TAG', '' ); // Change this to a secret placeholder tag
73
  if ( DYNAMIC_CACHE_TEST_TAG != '' ) {
74
  function dynamic_cache_test_safety( $safety ) {
75
  return 1;
76
  }
77
+ add_cacheaction( 'wpsc_cachedata_safety', 'dynamic_cache_test_safety' );
 
78
 
79
  function dynamic_cache_test_filter( &$cachedata) {
80
  return str_replace( DYNAMIC_CACHE_TEST_TAG, "<!-- Hello world at " . date( 'H:i:s' ) . " -->", $cachedata );
plugins/jetpack.php CHANGED
@@ -59,7 +59,7 @@ function wp_super_cache_jetpack_cookie_check( $cache_key ) {
59
  else
60
  return 'normal';
61
  } else {
62
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_super_cache_jetpack_cookie_check: jetpack UA file not found." );
63
  return "normal";
64
  }
65
  }
59
  else
60
  return 'normal';
61
  } else {
62
+ wp_cache_debug( "wp_super_cache_jetpack_cookie_check: jetpack UA file not found." );
63
  return "normal";
64
  }
65
  }
readme.txt CHANGED
@@ -1,8 +1,8 @@
1
  === WP Super Cache ===
2
  Contributors: donncha, automattic
3
  Tags: performance,caching,wp-cache,wp-super-cache,cache
4
- Tested up to: 4.1
5
- Stable tag: 1.4.2
6
  Requires at least: 3.0
7
 
8
  A very fast caching engine for WordPress that produces static html files.
@@ -48,6 +48,8 @@ With preloading on cached files will still be deleted when posts are made or edi
48
 
49
  See the [WP Super Cache homepage](http://ocaoimh.ie/wp-super-cache/) for further information. [Developer documentation](http://ocaoimh.ie/wp-super-cache-developers/) is also available for those who need to interact with the cache or write plugins.
50
 
 
 
51
  The [changelog](http://svn.wp-plugins.org/wp-super-cache/trunk/Changelog.txt) is a good place to start if you want to know what has changed since you last downloaded the plugin.
52
 
53
  Interested in translating WP Super Cache to your language? Grab the [development version](http://downloads.wordpress.org/plugin/wp-super-cache.zip) where you will find an up to date wp-super-cache.pot. Send any translation files to donncha @ ocaoimh.ie and thank you!
@@ -56,10 +58,15 @@ The cache directory, usually wp-content/cache/ is only for temporary files. Do n
56
 
57
  == Upgrade Notice ==
58
 
59
- = 1.4.2 =
60
- Fixed "acceptable file list" and no caching for GET queries bugs in last release.
61
 
62
  == Changelog ==
 
 
 
 
 
63
  = 1.4.2 =
64
  * Fixed "acceptable file list".
65
  * Fixed "Don't cache GET requests" feature.
1
  === WP Super Cache ===
2
  Contributors: donncha, automattic
3
  Tags: performance,caching,wp-cache,wp-super-cache,cache
4
+ Tested up to: 4.1.1
5
+ Stable tag: 1.4.3
6
  Requires at least: 3.0
7
 
8
  A very fast caching engine for WordPress that produces static html files.
48
 
49
  See the [WP Super Cache homepage](http://ocaoimh.ie/wp-super-cache/) for further information. [Developer documentation](http://ocaoimh.ie/wp-super-cache-developers/) is also available for those who need to interact with the cache or write plugins.
50
 
51
+ There's a [GIT repository](https://github.com/Automattic/wp-super-cache) too if you want to contribute a patch.
52
+
53
  The [changelog](http://svn.wp-plugins.org/wp-super-cache/trunk/Changelog.txt) is a good place to start if you want to know what has changed since you last downloaded the plugin.
54
 
55
  Interested in translating WP Super Cache to your language? Grab the [development version](http://downloads.wordpress.org/plugin/wp-super-cache.zip) where you will find an up to date wp-super-cache.pot. Send any translation files to donncha @ ocaoimh.ie and thank you!
58
 
59
  == Upgrade Notice ==
60
 
61
+ = 1.4.3 =
62
+ Security release fixing an XSS bug in the settings page.
63
 
64
  == Changelog ==
65
+ = 1.4.3 =
66
+ * Security release fixing an XSS bug in the settings page. Props Marc Montpas from Sucuri.
67
+ * Added wp_debug_log(). Props Jen Heilemann.
68
+ * Minor fixes.
69
+
70
  = 1.4.2 =
71
  * Fixed "acceptable file list".
72
  * Fixed "Don't cache GET requests" feature.
wp-cache-phase1.php CHANGED
@@ -105,7 +105,7 @@ function get_wp_cache_key( $url = false ) {
105
  }
106
 
107
  function wp_super_cache_init() {
108
- global $wp_cache_key, $key, $blogcacheid, $wp_cache_request_uri, $file_prefix, $blog_cache_dir, $meta_file, $cache_file, $cache_filename, $wp_super_cache_debug, $meta_pathname, $wp_cache_gzip_encoding, $meta;
109
 
110
  $wp_cache_key = get_wp_cache_key();
111
  $key = $blogcacheid . md5( $wp_cache_key );
@@ -119,25 +119,25 @@ function wp_super_cache_init() {
119
  }
120
 
121
  function wp_cache_serve_cache_file() {
122
- global $key, $blogcacheid, $wp_cache_request_uri, $file_prefix, $blog_cache_dir, $meta_file, $cache_file, $cache_filename, $wp_super_cache_debug, $meta_pathname, $wp_cache_gzip_encoding, $meta;
123
  global $wp_cache_object_cache, $cache_compression, $wp_cache_slash_check, $wp_supercache_304, $wp_cache_home_path, $wp_cache_no_cache_for_get;
124
  global $wp_cache_disable_utf8, $wp_cache_mfunc_enabled;
125
 
126
  extract( wp_super_cache_init() );
127
 
128
  if ( wp_cache_user_agent_is_rejected() ) {
129
- if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "No wp-cache file served as user agent rejected.", 5 );
130
  return false;
131
  }
132
 
133
  if ( $wp_cache_no_cache_for_get && false == empty( $_GET ) ) {
134
- if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Non empty GET request. Caching disabled on settings page. " . print_r( $_GET, 1 ), 1 );
135
  return false;
136
  }
137
 
138
  if ( $wp_cache_object_cache && wp_cache_get_cookies_values() == '' ) {
139
  if ( !empty( $_GET ) ) {
140
- if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Non empty GET request. Not serving request from object cache. " . print_r( $_GET, 1 ), 1 );
141
  return false;
142
  }
143
 
@@ -150,17 +150,17 @@ function wp_cache_serve_cache_file() {
150
  $cache = wp_cache_get( $oc_key, 'supercache' );
151
  $meta = unserialize( wp_cache_get( $meta_filename, 'supercache' ) );
152
  if ( is_array( $meta ) == false ) {
153
- if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Meta array from object cache corrupt. Ignoring cache.", 1 );
154
  return true;
155
  }
156
  } elseif ( file_exists( $cache_file ) ) {
157
- if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "wp-cache file exists: $cache_file", 5 );
158
- if ( !( $meta = unserialize( @file_get_contents( $meta_pathname) ) ) ) {
159
- if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "couldn't load wp-cache meta file", 5 );
160
  return true;
161
  }
162
  if ( is_array( $meta ) == false ) {
163
- if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "meta array corrupt, deleting $meta_pathname and $cache_file", 1 );
164
  @unlink( $meta_pathname );
165
  @unlink( $cache_file );
166
  return true;
@@ -170,13 +170,13 @@ function wp_cache_serve_cache_file() {
170
  $filename = supercache_filename();
171
  $file = get_current_url_supercache_dir() . $filename;
172
  if ( false == file_exists( $file ) ) {
173
- if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "No Super Cache file found for current URL: $file" );
174
  return false;
175
  } elseif ( false == empty( $_GET ) ) {
176
- if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "GET array not empty. Cannot serve a supercache file. " . print_r( $_GET, 1 ) );
177
  return false;
178
  } elseif ( wp_cache_get_cookies_values() != '' ) {
179
- if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Cookies found. Cannot serve a supercache file. " . wp_cache_get_cookies_values() );
180
  return false;
181
  }
182
 
@@ -194,23 +194,23 @@ function wp_cache_serve_cache_file() {
194
  if ( $wp_cache_gzip_encoding ) {
195
  if ( file_exists( $file . '.gz' ) ) {
196
  $cachefiledata = file_get_contents( $file . '.gz' );
197
- if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Fetched gzip static page data from supercache file using PHP. File: $file.gz" );
198
  } else {
199
  $cachefiledata = gzencode( file_get_contents( $file ), 6, FORCE_GZIP );
200
- if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Fetched static page data from supercache file using PHP and gzipped it. File: $file" );
201
  }
202
  } else {
203
  $cachefiledata = file_get_contents( $file );
204
- if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Fetched static page data from supercache file using PHP. File: $file" );
205
  }
206
  } else {
207
  // get dynamic data from filtered file
208
  $cachefiledata = do_cacheaction( 'wpsc_cachedata', file_get_contents( $file ) );
209
  if ( $wp_cache_gzip_encoding ) {
210
  $cachefiledata = gzencode( $cachefiledata, 6, FORCE_GZIP );
211
- if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Fetched dynamic page data from supercache file using PHP and gzipped it. File: $file" );
212
  } else {
213
- if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Fetched dynamic page data from supercache file using PHP. File: $file" );
214
  }
215
  }
216
 
@@ -249,7 +249,7 @@ function wp_cache_serve_cache_file() {
249
  echo $cachefiledata;
250
  exit();
251
  } else {
252
- if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "No wp-cache file exists. Must generate a new one." );
253
  return false;
254
  }
255
  }
@@ -258,7 +258,7 @@ function wp_cache_serve_cache_file() {
258
  // Sometimes the gzip headers are lost. Make sure html returned isn't compressed!
259
  if ( $cache_compression && $wp_cache_gzip_encoding && !in_array( 'Content-Encoding: ' . $wp_cache_gzip_encoding, $meta[ 'headers' ] ) ) {
260
  $ungzip = true;
261
- if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "GZIP headers not found. Force uncompressed output.", 1 );
262
  } else {
263
  $ungzip = false;
264
  }
@@ -274,30 +274,30 @@ function wp_cache_serve_cache_file() {
274
  // attempt to uncompress the cached file just in case it's gzipped
275
  $uncompressed = gzuncompress( $cache );
276
  if ( $uncompressed ) {
277
- if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Uncompressed gzipped cache file from object cache", 1 );
278
  $cache = $uncompressed;
279
  unset( $uncompressed );
280
  }
281
  }
282
  if ( isset( $meta[ 'dynamic' ] ) && $meta[ 'dynamic' ] ) {
283
- if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Serving wp-cache dynamic file from object cache", 5 );
284
  echo do_cacheaction( 'wpsc_cachedata', $cache );
285
  } else {
286
- if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Serving wp-cache static file from object cache", 5 );
287
  echo $cache;
288
  }
289
- if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "exit request", 5 );
290
  die();
291
  }
292
  } else {
293
  if ( isset( $meta[ 'dynamic' ] ) ) {
294
- if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Serving wp-cache dynamic file", 5 );
295
  if ( $ungzip ) {
296
  // attempt to uncompress the cached file just in case it's gzipped
297
  $cache = file_get_contents( $cache_file );
298
  $uncompressed = @gzuncompress( $cache );
299
  if ( $uncompressed ) {
300
- if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Uncompressed gzipped cache file from wp-cache", 1 );
301
  unset( $cache );
302
  echo do_cacheaction( 'wpsc_cachedata', $uncompressed );
303
  } else {
@@ -307,12 +307,12 @@ function wp_cache_serve_cache_file() {
307
  echo do_cacheaction( 'wpsc_cachedata', file_get_contents( $cache_file ) );
308
  }
309
  } else {
310
- if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Serving wp-cache static file", 5 );
311
  if ( $ungzip ) {
312
  $cache = file_get_contents( $cache_file );
313
  $uncompressed = gzuncompress( $cache );
314
  if ( $uncompressed ) {
315
- if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Uncompressed gzipped cache file from wp-cache", 1 );
316
  echo $uncompressed;
317
  } else {
318
  echo $cache;
@@ -321,7 +321,7 @@ function wp_cache_serve_cache_file() {
321
  readfile( $cache_file );
322
  }
323
  }
324
- if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "exit request", 5 );
325
  die();
326
  }
327
  }
@@ -336,13 +336,13 @@ if ( !isset( $wp_super_cache_late_init ) || ( isset( $wp_super_cache_late_init )
336
  }
337
 
338
  function wp_cache_postload() {
339
- global $cache_enabled, $wp_super_cache_late_init, $wp_super_cache_debug;
340
 
341
  if ( !$cache_enabled )
342
  return true;
343
 
344
  if ( isset( $wp_super_cache_late_init ) && true == $wp_super_cache_late_init ) {
345
- if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Supercache Late Init: add wp_cache_serve_cache_file to init", 3 );
346
  add_action( 'init', 'wp_cache_late_loader', 9999 );
347
  } else {
348
  wp_super_cache_init();
@@ -351,8 +351,7 @@ function wp_cache_postload() {
351
  }
352
 
353
  function wp_cache_late_loader() {
354
- global $wp_super_cache_debug;
355
- if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Supercache Late Loader running on init", 3 );
356
  wp_cache_serve_cache_file();
357
  wp_cache_phase2();
358
  }
@@ -367,7 +366,7 @@ function wp_cache_get_cookies_values() {
367
  $regex .= "/";
368
  while ($key = key($_COOKIE)) {
369
  if ( preg_match( $regex, $key ) ) {
370
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cache_get_cookies_values: $regex Cookie detected: $key", 5 );
371
  $string .= $_COOKIE[ $key ] . ",";
372
  }
373
  next($_COOKIE);
@@ -423,16 +422,16 @@ function wp_cache_check_mobile( $cache_key ) {
423
  if ( !isset( $wp_cache_mobile_enabled ) || false == $wp_cache_mobile_enabled )
424
  return $cache_key;
425
 
426
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cache_check_mobile: $cache_key" );
427
 
428
  // allow plugins to short circuit mobile check. Cookie, extra UA checks?
429
  switch( do_cacheaction( 'wp_cache_check_mobile', $cache_key ) ) {
430
  case "normal":
431
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cache_check_mobile: desktop user agent detected by wp_cache_check_mobile action" );
432
  return $cache_key;
433
  break;
434
  case "mobile":
435
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cache_check_mobile: mobile user agent detected by wp_cache_check_mobile action" );
436
  return $cache_key . "-mobile";
437
  break;
438
  }
@@ -442,7 +441,7 @@ function wp_cache_check_mobile( $cache_key ) {
442
  }
443
 
444
  if ( do_cacheaction( 'disable_mobile_check', false ) ) {
445
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cache_check_mobile: disable_mobile_check disabled mobile check" );
446
  return $cache_key;
447
  }
448
 
@@ -450,7 +449,7 @@ function wp_cache_check_mobile( $cache_key ) {
450
  $user_agent = strtolower( $_SERVER['HTTP_USER_AGENT'] );
451
  foreach ($browsers as $browser) {
452
  if ( strstr( $user_agent, trim( strtolower( $browser ) ) ) ) {
453
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "mobile browser detected: " . $_SERVER[ "HTTP_USER_AGENT" ], 5 );
454
  return $cache_key . '-' . wp_cache_mobile_group( $user_agent );
455
  }
456
  }
@@ -463,7 +462,7 @@ function wp_cache_check_mobile( $cache_key ) {
463
  $browsers = explode( ',', $wp_cache_mobile_prefixes );
464
  foreach ($browsers as $browser_prefix) {
465
  if ( substr($user_agent, 0, 4) == $browser_prefix ) {
466
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "mobile browser (prefix) detected: " . $_SERVER[ "HTTP_USER_AGENT" ], 5 );
467
  return $cache_key . '-' . $browser_prefix;
468
  }
469
  }
@@ -480,21 +479,38 @@ function wp_cache_check_mobile( $cache_key ) {
480
  return $cache_key;
481
  }
482
 
 
 
 
 
 
 
483
  function wp_cache_debug( $message, $level = 1 ) {
484
  global $wp_cache_debug_log, $cache_path, $wp_cache_debug_ip, $wp_super_cache_debug;
485
 
486
- if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug == false )
 
 
487
  return false;
488
 
489
- if ( isset( $wp_cache_debug_log ) == false )
 
 
490
  return false;
491
 
492
- if ( isset( $wp_cache_debug_ip ) && $wp_cache_debug_ip != '' && $wp_cache_debug_ip != $_SERVER[ 'REMOTE_ADDR' ] )
 
 
 
 
493
  return false;
494
 
495
- if ( isset( $wp_cache_debug_log ) && $wp_cache_debug_log != '' ) {
496
- error_log( date( 'H:i:s' ) . " " . $_SERVER[ 'REQUEST_URI' ] . " " . $message . "\n", 3, $cache_path . str_replace( '/', '', str_replace( '..', '', $wp_cache_debug_log ) ) );
497
- }
 
 
 
498
  }
499
 
500
  function wp_cache_user_agent_is_rejected() {
@@ -538,15 +554,15 @@ function get_current_url_supercache_dir( $post_id = 0 ) {
538
  * Sometimes site_url doesn't return the siteurl. See http://wordpress.org/support/topic/wp-super-cache-not-refreshing-post-after-comments-made
539
  */
540
  $DONOTREMEMBER = 1;
541
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "get_current_url_supercache_dir: warning! site_url ($site_url) not found in permalink ($permalink).", 1 );
542
  if ( false === strpos( $permalink, $WPSC_HTTP_HOST ) ) {
543
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "get_current_url_supercache_dir: WARNING! SERVER_NAME ({$WPSC_HTTP_HOST}) not found in permalink ($permalink). ", 1 );
544
  $p = parse_url( $permalink );
545
  if ( is_array( $p ) ) {
546
  $uri = $p[ 'path' ];
547
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "get_current_url_supercache_dir: WARNING! Using $uri as permalink. Used parse_url.", 1 );
548
  } else {
549
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "get_current_url_supercache_dir: WARNING! Permalink ($permalink) could not be understood by parse_url. Using front page.", 1 );
550
  $uri = '';
551
  }
552
  } else {
@@ -554,7 +570,7 @@ function get_current_url_supercache_dir( $post_id = 0 ) {
554
  $protocol = ( 'on' == strtolower( $_SERVER[ 'HTTPS' ] ) ) ? 'https://' : 'http://';
555
  else
556
  $protocol = 'http://';
557
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "get_current_url_supercache_dir: Removing SERVER_NAME ({$WPSC_HTTP_HOST}) and $protocol from permalink ($permalink). Is the url right?", 1 );
558
  $uri = str_replace( $WPSC_HTTP_HOST, '', $permalink );
559
  $uri = str_replace( $protocol, '', $uri );
560
  }
@@ -579,7 +595,7 @@ function get_current_url_supercache_dir( $post_id = 0 ) {
579
  $dir = ABSPATH . $uri . '/';
580
  }
581
  $dir = str_replace( '//', '/', $dir );
582
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "supercache dir: $dir", 5 );
583
  if ( $DONOTREMEMBER == 0 )
584
  $saved_supercache_dir[ $post_id ] = $dir;
585
  return $dir;
@@ -673,7 +689,7 @@ function wp_supercache_cache_for_admins() {
673
  reset( $cookie_keys );
674
  foreach( $cookie_keys as $key ) {
675
  if ( strpos( $cookie, $key ) !== FALSE ) {
676
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Removing auth from $_COOKIE to allow caching for logged in user (' . $cookie . ')', 5 );
677
  unset( $_COOKIE[ $cookie ] );
678
  }
679
  }
105
  }
106
 
107
  function wp_super_cache_init() {
108
+ global $wp_cache_key, $key, $blogcacheid, $wp_cache_request_uri, $file_prefix, $blog_cache_dir, $meta_file, $cache_file, $cache_filename, $meta_pathname, $wp_cache_gzip_encoding, $meta;
109
 
110
  $wp_cache_key = get_wp_cache_key();
111
  $key = $blogcacheid . md5( $wp_cache_key );
119
  }
120
 
121
  function wp_cache_serve_cache_file() {
122
+ global $key, $blogcacheid, $wp_cache_request_uri, $file_prefix, $blog_cache_dir, $meta_file, $cache_file, $cache_filename, $meta_pathname, $wp_cache_gzip_encoding, $meta;
123
  global $wp_cache_object_cache, $cache_compression, $wp_cache_slash_check, $wp_supercache_304, $wp_cache_home_path, $wp_cache_no_cache_for_get;
124
  global $wp_cache_disable_utf8, $wp_cache_mfunc_enabled;
125
 
126
  extract( wp_super_cache_init() );
127
 
128
  if ( wp_cache_user_agent_is_rejected() ) {
129
+ wp_cache_debug( "No wp-cache file served as user agent rejected.", 5 );
130
  return false;
131
  }
132
 
133
  if ( $wp_cache_no_cache_for_get && false == empty( $_GET ) ) {
134
+ wp_cache_debug( "Non empty GET request. Caching disabled on settings page. " . print_r( $_GET, 1 ), 1 );
135
  return false;
136
  }
137
 
138
  if ( $wp_cache_object_cache && wp_cache_get_cookies_values() == '' ) {
139
  if ( !empty( $_GET ) ) {
140
+ wp_cache_debug( "Non empty GET request. Not serving request from object cache. " . print_r( $_GET, 1 ), 1 );
141
  return false;
142
  }
143
 
150
  $cache = wp_cache_get( $oc_key, 'supercache' );
151
  $meta = unserialize( wp_cache_get( $meta_filename, 'supercache' ) );
152
  if ( is_array( $meta ) == false ) {
153
+ wp_cache_debug( "Meta array from object cache corrupt. Ignoring cache.", 1 );
154
  return true;
155
  }
156
  } elseif ( file_exists( $cache_file ) ) {
157
+ wp_cache_debug( "wp-cache file exists: $cache_file", 5 );
158
+ if ( !( $meta = unserialize( @file_get_contents( $meta_pathname) ) ) ) {
159
+ wp_cache_debug( "couldn't load wp-cache meta file", 5 );
160
  return true;
161
  }
162
  if ( is_array( $meta ) == false ) {
163
+ wp_cache_debug( "meta array corrupt, deleting $meta_pathname and $cache_file", 1 );
164
  @unlink( $meta_pathname );
165
  @unlink( $cache_file );
166
  return true;
170
  $filename = supercache_filename();
171
  $file = get_current_url_supercache_dir() . $filename;
172
  if ( false == file_exists( $file ) ) {
173
+ wp_cache_debug( "No Super Cache file found for current URL: $file" );
174
  return false;
175
  } elseif ( false == empty( $_GET ) ) {
176
+ wp_cache_debug( "GET array not empty. Cannot serve a supercache file. " . print_r( $_GET, 1 ) );
177
  return false;
178
  } elseif ( wp_cache_get_cookies_values() != '' ) {
179
+ wp_cache_debug( "Cookies found. Cannot serve a supercache file. " . wp_cache_get_cookies_values() );
180
  return false;
181
  }
182
 
194
  if ( $wp_cache_gzip_encoding ) {
195
  if ( file_exists( $file . '.gz' ) ) {
196
  $cachefiledata = file_get_contents( $file . '.gz' );
197
+ wp_cache_debug( "Fetched gzip static page data from supercache file using PHP. File: $file.gz" );
198
  } else {
199
  $cachefiledata = gzencode( file_get_contents( $file ), 6, FORCE_GZIP );
200
+ wp_cache_debug( "Fetched static page data from supercache file using PHP and gzipped it. File: $file" );
201
  }
202
  } else {
203
  $cachefiledata = file_get_contents( $file );
204
+ wp_cache_debug( "Fetched static page data from supercache file using PHP. File: $file" );
205
  }
206
  } else {
207
  // get dynamic data from filtered file
208
  $cachefiledata = do_cacheaction( 'wpsc_cachedata', file_get_contents( $file ) );
209
  if ( $wp_cache_gzip_encoding ) {
210
  $cachefiledata = gzencode( $cachefiledata, 6, FORCE_GZIP );
211
+ wp_cache_debug( "Fetched dynamic page data from supercache file using PHP and gzipped it. File: $file" );
212
  } else {
213
+ wp_cache_debug( "Fetched dynamic page data from supercache file using PHP. File: $file" );
214
  }
215
  }
216
 
249
  echo $cachefiledata;
250
  exit();
251
  } else {
252
+ wp_cache_debug( "No wp-cache file exists. Must generate a new one." );
253
  return false;
254
  }
255
  }
258
  // Sometimes the gzip headers are lost. Make sure html returned isn't compressed!
259
  if ( $cache_compression && $wp_cache_gzip_encoding && !in_array( 'Content-Encoding: ' . $wp_cache_gzip_encoding, $meta[ 'headers' ] ) ) {
260
  $ungzip = true;
261
+ wp_cache_debug( "GZIP headers not found. Force uncompressed output.", 1 );
262
  } else {
263
  $ungzip = false;
264
  }
274
  // attempt to uncompress the cached file just in case it's gzipped
275
  $uncompressed = gzuncompress( $cache );
276
  if ( $uncompressed ) {
277
+ wp_cache_debug( "Uncompressed gzipped cache file from object cache", 1 );
278
  $cache = $uncompressed;
279
  unset( $uncompressed );
280
  }
281
  }
282
  if ( isset( $meta[ 'dynamic' ] ) && $meta[ 'dynamic' ] ) {
283
+ wp_cache_debug( "Serving wp-cache dynamic file from object cache", 5 );
284
  echo do_cacheaction( 'wpsc_cachedata', $cache );
285
  } else {
286
+ wp_cache_debug( "Serving wp-cache static file from object cache", 5 );
287
  echo $cache;
288
  }
289
+ wp_cache_debug( "exit request", 5 );
290
  die();
291
  }
292
  } else {
293
  if ( isset( $meta[ 'dynamic' ] ) ) {
294
+ wp_cache_debug( "Serving wp-cache dynamic file", 5 );
295
  if ( $ungzip ) {
296
  // attempt to uncompress the cached file just in case it's gzipped
297
  $cache = file_get_contents( $cache_file );
298
  $uncompressed = @gzuncompress( $cache );
299
  if ( $uncompressed ) {
300
+ wp_cache_debug( "Uncompressed gzipped cache file from wp-cache", 1 );
301
  unset( $cache );
302
  echo do_cacheaction( 'wpsc_cachedata', $uncompressed );
303
  } else {
307
  echo do_cacheaction( 'wpsc_cachedata', file_get_contents( $cache_file ) );
308
  }
309
  } else {
310
+ wp_cache_debug( "Serving wp-cache static file", 5 );
311
  if ( $ungzip ) {
312
  $cache = file_get_contents( $cache_file );
313
  $uncompressed = gzuncompress( $cache );
314
  if ( $uncompressed ) {
315
+ wp_cache_debug( "Uncompressed gzipped cache file from wp-cache", 1 );
316
  echo $uncompressed;
317
  } else {
318
  echo $cache;
321
  readfile( $cache_file );
322
  }
323
  }
324
+ wp_cache_debug( "exit request", 5 );
325
  die();
326
  }
327
  }
336
  }
337
 
338
  function wp_cache_postload() {
339
+ global $cache_enabled, $wp_super_cache_late_init;
340
 
341
  if ( !$cache_enabled )
342
  return true;
343
 
344
  if ( isset( $wp_super_cache_late_init ) && true == $wp_super_cache_late_init ) {
345
+ wp_cache_debug( "Supercache Late Init: add wp_cache_serve_cache_file to init", 3 );
346
  add_action( 'init', 'wp_cache_late_loader', 9999 );
347
  } else {
348
  wp_super_cache_init();
351
  }
352
 
353
  function wp_cache_late_loader() {
354
+ wp_cache_debug( "Supercache Late Loader running on init", 3 );
 
355
  wp_cache_serve_cache_file();
356
  wp_cache_phase2();
357
  }
366
  $regex .= "/";
367
  while ($key = key($_COOKIE)) {
368
  if ( preg_match( $regex, $key ) ) {
369
+ wp_cache_debug( "wp_cache_get_cookies_values: $regex Cookie detected: $key", 5 );
370
  $string .= $_COOKIE[ $key ] . ",";
371
  }
372
  next($_COOKIE);
422
  if ( !isset( $wp_cache_mobile_enabled ) || false == $wp_cache_mobile_enabled )
423
  return $cache_key;
424
 
425
+ wp_cache_debug( "wp_cache_check_mobile: $cache_key" );
426
 
427
  // allow plugins to short circuit mobile check. Cookie, extra UA checks?
428
  switch( do_cacheaction( 'wp_cache_check_mobile', $cache_key ) ) {
429
  case "normal":
430
+ wp_cache_debug( "wp_cache_check_mobile: desktop user agent detected by wp_cache_check_mobile action" );
431
  return $cache_key;
432
  break;
433
  case "mobile":
434
+ wp_cache_debug( "wp_cache_check_mobile: mobile user agent detected by wp_cache_check_mobile action" );
435
  return $cache_key . "-mobile";
436
  break;
437
  }
441
  }
442
 
443
  if ( do_cacheaction( 'disable_mobile_check', false ) ) {
444
+ wp_cache_debug( "wp_cache_check_mobile: disable_mobile_check disabled mobile check" );
445
  return $cache_key;
446
  }
447
 
449
  $user_agent = strtolower( $_SERVER['HTTP_USER_AGENT'] );
450
  foreach ($browsers as $browser) {
451
  if ( strstr( $user_agent, trim( strtolower( $browser ) ) ) ) {
452
+ wp_cache_debug( "mobile browser detected: " . $_SERVER[ "HTTP_USER_AGENT" ], 5 );
453
  return $cache_key . '-' . wp_cache_mobile_group( $user_agent );
454
  }
455
  }
462
  $browsers = explode( ',', $wp_cache_mobile_prefixes );
463
  foreach ($browsers as $browser_prefix) {
464
  if ( substr($user_agent, 0, 4) == $browser_prefix ) {
465
+ wp_cache_debug( "mobile browser (prefix) detected: " . $_SERVER[ "HTTP_USER_AGENT" ], 5 );
466
  return $cache_key . '-' . $browser_prefix;
467
  }
468
  }
479
  return $cache_key;
480
  }
481
 
482
+ /**
483
+ * Add a log message to the file, if debugging is turned on
484
+ *
485
+ * @param $message string The message that should be added to the log
486
+ * @param $level int
487
+ */
488
  function wp_cache_debug( $message, $level = 1 ) {
489
  global $wp_cache_debug_log, $cache_path, $wp_cache_debug_ip, $wp_super_cache_debug;
490
 
491
+ // If either of the debug or log globals aren't set, then we can stop
492
+ if ( !isset($wp_super_cache_debug)
493
+ || !isset($wp_cache_debug_log) )
494
  return false;
495
 
496
+ // If either the debug or log globals are false or empty, we can stop
497
+ if ( $wp_super_cache_debug == false
498
+ || $wp_cache_debug_log == '' )
499
  return false;
500
 
501
+ // If the debug_ip has been set, but it doesn't match the ip of the requester
502
+ // then we can stop.
503
+ if ( isset($wp_cache_debug_ip)
504
+ && $wp_cache_debug_ip != ''
505
+ && $wp_cache_debug_ip != $_SERVER[ 'REMOTE_ADDR' ] )
506
  return false;
507
 
508
+ // Log message: Date URI Message
509
+ $log_messase = date('H:i:s') . " {$_SERVER['REQUEST_URI']} {$message}\n\r";
510
+ // path to the log file in the cache folder
511
+ $log_file = $cache_path . str_replace('/', '', str_replace('..', '', $wp_cache_debug_log));
512
+
513
+ error_log($log_message, 3, $log_file);
514
  }
515
 
516
  function wp_cache_user_agent_is_rejected() {
554
  * Sometimes site_url doesn't return the siteurl. See http://wordpress.org/support/topic/wp-super-cache-not-refreshing-post-after-comments-made
555
  */
556
  $DONOTREMEMBER = 1;
557
+ wp_cache_debug( "get_current_url_supercache_dir: warning! site_url ($site_url) not found in permalink ($permalink).", 1 );
558
  if ( false === strpos( $permalink, $WPSC_HTTP_HOST ) ) {
559
+ wp_cache_debug( "get_current_url_supercache_dir: WARNING! SERVER_NAME ({$WPSC_HTTP_HOST}) not found in permalink ($permalink). ", 1 );
560
  $p = parse_url( $permalink );
561
  if ( is_array( $p ) ) {
562
  $uri = $p[ 'path' ];
563
+ wp_cache_debug( "get_current_url_supercache_dir: WARNING! Using $uri as permalink. Used parse_url.", 1 );
564
  } else {
565
+ wp_cache_debug( "get_current_url_supercache_dir: WARNING! Permalink ($permalink) could not be understood by parse_url. Using front page.", 1 );
566
  $uri = '';
567
  }
568
  } else {
570
  $protocol = ( 'on' == strtolower( $_SERVER[ 'HTTPS' ] ) ) ? 'https://' : 'http://';
571
  else
572
  $protocol = 'http://';
573
+ wp_cache_debug( "get_current_url_supercache_dir: Removing SERVER_NAME ({$WPSC_HTTP_HOST}) and $protocol from permalink ($permalink). Is the url right?", 1 );
574
  $uri = str_replace( $WPSC_HTTP_HOST, '', $permalink );
575
  $uri = str_replace( $protocol, '', $uri );
576
  }
595
  $dir = ABSPATH . $uri . '/';
596
  }
597
  $dir = str_replace( '//', '/', $dir );
598
+ wp_cache_debug( "supercache dir: $dir", 5 );
599
  if ( $DONOTREMEMBER == 0 )
600
  $saved_supercache_dir[ $post_id ] = $dir;
601
  return $dir;
689
  reset( $cookie_keys );
690
  foreach( $cookie_keys as $key ) {
691
  if ( strpos( $cookie, $key ) !== FALSE ) {
692
+ wp_cache_debug( 'Removing auth from $_COOKIE to allow caching for logged in user (' . $cookie . ')', 5 );
693
  unset( $_COOKIE[ $cookie ] );
694
  }
695
  }
wp-cache-phase2.php CHANGED
@@ -6,18 +6,18 @@ function wp_cache_phase2() {
6
  global $cache_enabled, $wp_cache_gmt_offset, $wp_cache_blog_charset, $cache_schedule_type, $cache_scheduled_time, $cache_schedule_interval;
7
 
8
  if ( $cache_enabled == false ) {
9
- if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Caching disabled! quiting!", 1 );
10
  return false;
11
  }
12
 
13
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'In WP Cache Phase 2', 5 );
14
 
15
  $wp_cache_gmt_offset = get_option( 'gmt_offset' ); // caching for later use when wpdb is gone. http://wordpress.org/support/topic/224349
16
  $wp_cache_blog_charset = get_option( 'blog_charset' );
17
 
18
  wp_cache_mutex_init();
19
  if(function_exists('add_action') && ( !defined( 'WPLOCKDOWN' ) || ( defined( 'WPLOCKDOWN' ) && constant( 'WPLOCKDOWN' ) == '0' ) ) ) {
20
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Setting up WordPress actions', 5 );
21
 
22
  add_action( 'template_redirect', 'wp_super_cache_query_vars' );
23
 
@@ -47,12 +47,12 @@ function wp_cache_phase2() {
47
  }
48
 
49
  if ( is_admin() ) {
50
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching wp-admin requests.', 5 );
51
  return false;
52
  }
53
 
54
  if ( !empty( $_GET ) ) {
55
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Supercache caching disabled. Only using wp-cache. Non empty GET request. ' . print_r( $_GET, 1 ), 5 );
56
  $super_cache_enabled = false;
57
  }
58
 
@@ -61,7 +61,7 @@ function wp_cache_phase2() {
61
  else
62
  header('Vary: Cookie');
63
  ob_start( 'wp_cache_ob_callback' );
64
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Created output buffer', 4 );
65
 
66
  // restore old supercache file temporarily
67
  if( $super_cache_enabled && $cache_rebuild_files ) {
@@ -83,12 +83,12 @@ function wpcache_do_rebuild( $dir ) {
83
  continue;
84
  $mtime = @filemtime($cache_file . '.needs-rebuild');
85
  if( $mtime && (time() - $mtime) < 30 ) {
86
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Rebuild file renamed to cache file temporarily: $cache_file", 3 );
87
  @rename( $cache_file . '.needs-rebuild', $cache_file );
88
  }
89
  // cleanup old files or if rename fails
90
  if( @file_exists( $cache_file . '.needs-rebuild' ) ) {
91
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Rebuild file deleted: {$cache_file}.needs-rebuild", 3 );
92
  @unlink( $cache_file . '.needs-rebuild' );
93
  }
94
  }
@@ -164,10 +164,10 @@ function wp_cache_mutex_init() {
164
  $mutex = false;
165
  if ($use_flock ) {
166
  setup_blog_cache_dir();
167
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Created mutex lock on filename: {$blog_cache_dir}{$mutex_filename}", 5 );
168
  $mutex = @fopen( $blog_cache_dir . $mutex_filename, 'w' );
169
  } else {
170
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Created mutex lock on semaphore: {$sem_id}", 5 );
171
  $mutex = @sem_get( $sem_id, 1, 0644 | IPC_CREAT, 1 );
172
  }
173
  }
@@ -179,15 +179,15 @@ function wp_cache_writers_entry() {
179
  return true;
180
 
181
  if( !$mutex ) {
182
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "(writers entry) mutex lock not created. not caching.", 2 );
183
  return false;
184
  }
185
 
186
  if ( $use_flock ) {
187
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "grabbing lock using flock()", 5 );
188
  flock($mutex, LOCK_EX);
189
  } else {
190
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "grabbing lock using sem_acquire()", 5 );
191
  sem_acquire($mutex);
192
  }
193
 
@@ -201,15 +201,15 @@ function wp_cache_writers_exit() {
201
  return true;
202
 
203
  if( !$mutex ) {
204
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "(writers exit) mutex lock not created. not caching.", 2 );
205
  return false;
206
  }
207
 
208
  if ( $use_flock ) {
209
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "releasing lock using flock()", 5 );
210
  flock($mutex, LOCK_UN);
211
  } else {
212
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "releasing lock using sem_release()", 5 );
213
  sem_release($mutex);
214
  }
215
  }
@@ -247,64 +247,64 @@ function wp_cache_ob_callback( $buffer ) {
247
  // All the things that can stop a page being cached
248
  $cache_this_page = true;
249
  if ( defined( 'DONOTCACHEPAGE' ) ) {
250
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'DONOTCACHEPAGE defined. Caching disabled.', 2 );
251
  $cache_this_page = false;
252
  } elseif ( $wp_cache_no_cache_for_get && false == empty( $_GET ) && false == defined( 'DOING_CRON' ) ) {
253
- if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Non empty GET request. Caching disabled on settings page. " . print_r( $_GET, 1 ), 1 );
254
  $cache_this_page = false;
255
  } elseif ( $_SERVER["REQUEST_METHOD"] == 'POST' || !empty( $_POST ) || get_option( 'gzipcompression' ) ) {
256
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching POST request.', 5 );
257
  $cache_this_page = false;
258
  } elseif ( $wp_cache_object_cache && !empty( $_GET ) ) {
259
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching GET request while object cache storage enabled.', 5 );
260
  $cache_this_page = false;
261
  } elseif ( isset( $_GET[ 'preview' ] ) ) {
262
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching preview post.', 2 );
263
  $cache_this_page = false;
264
  } elseif ( !in_array($script, $cache_acceptable_files) && wp_cache_is_rejected( $wp_cache_request_uri ) ) {
265
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'URI rejected. Not Caching', 2 );
266
  $cache_this_page = false;
267
  } elseif ( wp_cache_user_agent_is_rejected() ) {
268
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "USER AGENT ({$_SERVER[ 'HTTP_USER_AGENT' ]}) rejected. Not Caching", 4 );
269
  $cache_this_page = false;
270
  } elseif ( isset( $wp_cache_pages[ 'single' ] ) && $wp_cache_pages[ 'single' ] == 1 && isset( $wp_super_cache_query[ 'is_single' ] ) ) {
271
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching single post.', 2 );
272
  $cache_this_page = false;
273
  } elseif ( isset( $wp_cache_pages[ 'pages' ] ) && $wp_cache_pages[ 'pages' ] == 1 && isset( $wp_super_cache_query[ 'is_page' ] ) ) {
274
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching single page.', 2 );
275
  $cache_this_page = false;
276
  } elseif ( isset( $wp_cache_pages[ 'archives' ] ) && $wp_cache_pages[ 'archives' ] == 1 && isset( $wp_super_cache_query[ 'is_archive' ] ) ) {
277
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching archive page.', 2 );
278
  $cache_this_page = false;
279
  } elseif ( isset( $wp_cache_pages[ 'tag' ] ) && $wp_cache_pages[ 'tag' ] == 1 && isset( $wp_super_cache_query[ 'is_tag' ] ) ) {
280
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching tag page.', 2 );
281
  $cache_this_page = false;
282
  } elseif ( isset( $wp_cache_pages[ 'category' ] ) && $wp_cache_pages[ 'category' ] == 1 && isset( $wp_super_cache_query[ 'is_category' ] ) ) {
283
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching category page.', 2 );
284
  $cache_this_page = false;
285
  } elseif ( isset( $wp_cache_pages[ 'frontpage' ] ) && $wp_cache_pages[ 'frontpage' ] == 1 && isset( $wp_super_cache_query[ 'is_front_page' ] ) ) {
286
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching front page.', 2 );
287
  $cache_this_page = false;
288
  } elseif ( isset( $wp_cache_pages[ 'home' ] ) && $wp_cache_pages[ 'home' ] == 1 && isset( $wp_super_cache_query[ 'is_home' ] ) ) {
289
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching home page.', 2 );
290
  $cache_this_page = false;
291
  } elseif ( isset( $wp_cache_pages[ 'search' ] ) && $wp_cache_pages[ 'search' ] == 1 && isset( $wp_super_cache_query[ 'is_search' ] ) ) {
292
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching search page.', 2 );
293
  $cache_this_page = false;
294
  } elseif ( isset( $wp_cache_pages[ 'author' ] ) && $wp_cache_pages[ 'author' ] == 1 && isset( $wp_super_cache_query[ 'is_author' ] ) ) {
295
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching author page.', 2 );
296
  $cache_this_page = false;
297
  } elseif ( isset( $wp_cache_pages[ 'feed' ] ) && $wp_cache_pages[ 'feed' ] == 1 && isset( $wp_super_cache_query[ 'is_feed' ] ) ) {
298
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching feed.', 2 );
299
  $cache_this_page = false;
300
  }
301
 
302
  if ( !isset( $wp_query ) )
303
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'wp_cache_ob_callback: WARNING! $query not defined but the plugin has worked around that problem.', 4 );
304
 
305
  if ( $cache_this_page ) {
306
 
307
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Output buffer callback', 4 );
308
 
309
  $buffer = wp_cache_get_ob( $buffer );
310
  wp_cache_shutdown_callback();
@@ -351,10 +351,10 @@ function wp_cache_add_to_buffer( &$buffer, $text ) {
351
  function wp_cache_maybe_dynamic( &$buffer ) {
352
  global $wp_cache_mfunc_enabled;
353
  if ( $wp_cache_mfunc_enabled == 1 && do_cacheaction( 'wpsc_cachedata_safety', 0 ) === 1 ) {
354
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'wp_cache_maybe_dynamic: filtered $buffer through wpsc_cachedata', 4 );
355
  return do_cacheaction( 'wpsc_cachedata', $buffer ); // dynamic content for display
356
  } else {
357
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'wp_cache_maybe_dynamic: returned $buffer', 4 );
358
  return $buffer;
359
  }
360
  }
@@ -400,7 +400,7 @@ function wp_cache_get_ob(&$buffer) {
400
  wp_cache_add_to_buffer( $buffer, "Page not cached by WP Super Cache. No closing HTML tag. Check your theme." );
401
  }
402
  } else {
403
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "robots.txt detected. Not caching.", 2 );
404
  }
405
  }
406
 
@@ -413,12 +413,12 @@ function wp_cache_get_ob(&$buffer) {
413
 
414
  if( !wp_cache_writers_entry() ) {
415
  wp_cache_add_to_buffer( $buffer, "Page not cached by WP Super Cache. Could not get mutex lock." );
416
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Could not get mutex lock. Not caching.", 1 );
417
  return wp_cache_maybe_dynamic( $buffer );
418
  }
419
 
420
  if ( $wp_cache_not_logged_in && is_feed() ) {
421
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Feed detected. Writing legacy cache files.", 5 );
422
  $wp_cache_not_logged_in = false;
423
  }
424
 
@@ -427,7 +427,7 @@ function wp_cache_get_ob(&$buffer) {
427
  $dir = get_current_url_supercache_dir();
428
  $supercachedir = $cache_path . 'supercache/' . preg_replace('/:.*$/', '', $home_url[ 'host' ]);
429
  if( !empty( $_GET ) || is_feed() || ( $super_cache_enabled == true && is_dir( substr( $supercachedir, 0, -1 ) . '.disabled' ) ) ) {
430
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Supercache disabled: GET or feed detected or disabled by config.", 2 );
431
  $super_cache_enabled = false;
432
  }
433
 
@@ -436,7 +436,7 @@ function wp_cache_get_ob(&$buffer) {
436
  $supercacheonly = false;
437
  if( $super_cache_enabled ) {
438
  if ( wp_cache_get_cookies_values() == '' && empty( $_GET ) ) {
439
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Anonymous user detected. Only creating Supercache file.", 3 );
440
  $supercacheonly = true;
441
  }
442
  }
@@ -446,7 +446,7 @@ function wp_cache_get_ob(&$buffer) {
446
  $super_cache_enabled = false;
447
  $cache_enabled = false;
448
  $cache_error = 'Not caching requests by known users. (See Advanced Settings page)';
449
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching for known user.', 5 );
450
  }
451
 
452
  if ( $wp_cache_object_cache ) { // half on mode when using the object cache
@@ -460,7 +460,7 @@ function wp_cache_get_ob(&$buffer) {
460
  }
461
 
462
  if ( !$cache_enabled ) {
463
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Cache is not enabled. Sending buffer to browser.', 5 );
464
  wp_cache_writers_exit();
465
  wp_cache_add_to_buffer( $buffer, "Page not cached by WP Super Cache. Check your settings page. $cache_error" );
466
  if ( $wp_cache_mfunc_enabled == 1 ) {
@@ -481,7 +481,7 @@ function wp_cache_get_ob(&$buffer) {
481
  if ( !$supercacheonly ) {
482
  $fr = @fopen($tmp_wpcache_filename, 'w');
483
  if (!$fr) {
484
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Error. Supercache could not write to " . str_replace( ABSPATH, '', $cache_path ) . $cache_filename, 1 );
485
  wp_cache_add_to_buffer( $buffer, "File not cached! Super Cache Couldn't write to: " . str_replace( ABSPATH, '', $cache_path ) . $cache_filename );
486
  wp_cache_writers_exit();
487
  return wp_cache_maybe_dynamic( $buffer );
@@ -495,7 +495,7 @@ function wp_cache_get_ob(&$buffer) {
495
  $tmp_cache_filename = $dir . uniqid( mt_rand(), true ) . '.tmp';
496
  $fr2 = @fopen( $tmp_cache_filename, 'w' );
497
  if ( !$fr2 ) {
498
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Error. Supercache could not write to " . str_replace( ABSPATH, '', $tmp_cache_filename ), 1 );
499
  wp_cache_add_to_buffer( $buffer, "File not cached! Super Cache Couldn't write to: " . str_replace( ABSPATH, '', $tmp_cache_filename ) );
500
  @fclose( $fr );
501
  @unlink( $tmp_wpcache_filename );
@@ -504,7 +504,7 @@ function wp_cache_get_ob(&$buffer) {
504
  } elseif ( ( !isset( $wp_cache_mfunc_enabled ) || $wp_cache_mfunc_enabled == 0 ) && $cache_compression ) { // don't want to store compressed files if using dynamic content
505
  $gz = @fopen( $tmp_cache_filename . ".gz", 'w');
506
  if (!$gz) {
507
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Error. Supercache could not write to " . str_replace( ABSPATH, '', $tmp_cache_filename ) . ".gz", 1 );
508
  wp_cache_add_to_buffer( $buffer, "File not cached! Super Cache Couldn't write to: " . str_replace( ABSPATH, '', $tmp_cache_filename ) . ".gz" );
509
  @fclose( $fr );
510
  @unlink( $tmp_wpcache_filename );
@@ -529,7 +529,7 @@ function wp_cache_get_ob(&$buffer) {
529
  */
530
  if ( $wp_cache_mfunc_enabled == 1 ) {
531
  if ( preg_match( '/<!--mclude|<!--mfunc|<!--dynamic-cached-content-->/', $buffer ) ) { //Dynamic content
532
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "mfunc/mclude/dynamic-cached-content tags have been retired. Please update your theme. See docs for updates." );
533
  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." );
534
  }
535
 
@@ -538,11 +538,11 @@ function wp_cache_get_ob(&$buffer) {
538
  wp_cache_add_to_buffer( $buffer, 'Super Cache dynamic page detected but late init not set. See the readme.txt for further details.' );
539
 
540
  if ( $fr ) { // legacy caching
541
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Writing dynamic buffer to legacy file." );
542
  wp_cache_add_to_buffer( $buffer, "Dynamic Legacy Super Cache" );
543
  fputs( $fr, $buffer );
544
  } elseif ( isset( $fr2 ) ) { // supercache active
545
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Writing dynamic buffer to supercache file." );
546
  wp_cache_add_to_buffer( $buffer, "Dynamic Super Cache" );
547
  fputs( $fr2, $buffer );
548
  } elseif ( true == $wp_cache_object_cache ) {
@@ -553,14 +553,14 @@ function wp_cache_get_ob(&$buffer) {
553
  $buffer = do_cacheaction( 'wpsc_cachedata', $buffer ); // dynamic content for display
554
 
555
  if ( $cache_compression && $wp_cache_gzip_encoding ) {
556
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Gzipping dynamic buffer for display.", 5 );
557
  wp_cache_add_to_buffer( $buffer, "Compression = gzip" );
558
  $gzdata = gzencode( $buffer, 6, FORCE_GZIP );
559
  $gzsize = function_exists( 'mb_strlen' ) ? mb_strlen( $gzdata, '8bit' ) : strlen( $gzdata );
560
  }
561
  } else {
562
  if ( $gz || $wp_cache_gzip_encoding ) {
563
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Gzipping buffer.", 5 );
564
  wp_cache_add_to_buffer( $buffer, "Compression = gzip" );
565
  $gzdata = gzencode( $buffer, 6, FORCE_GZIP );
566
  $gzsize = function_exists( 'mb_strlen' ) ? mb_strlen( $gzdata, '8bit' ) : strlen( $gzdata );
@@ -569,7 +569,7 @@ function wp_cache_get_ob(&$buffer) {
569
  $wp_cache_meta[ 'headers' ][ 'Vary' ] = 'Vary: Accept-Encoding, Cookie';
570
  // Return uncompressed data & store compressed for later use
571
  if ( $fr ) {
572
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Writing gzipped buffer to wp-cache cache file.", 5 );
573
  fputs($fr, $gzdata);
574
  } elseif ( $cache_enabled && $wp_cache_object_cache ) {
575
  wp_cache_set( $oc_key . ".gz", $gzdata, 'supercache', $cache_max_time );
@@ -581,17 +581,17 @@ function wp_cache_get_ob(&$buffer) {
581
  wp_cache_set( $oc_key, $buffer, 'supercache', $cache_max_time );
582
  $added_cache = 1;
583
  } elseif ( $fr ) {
584
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Writing non-gzipped buffer to wp-cache cache file." );
585
  fputs($fr, $buffer);
586
  }
587
  }
588
  if ( $fr2 ) {
589
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Writing non-gzipped buffer to supercache file." );
590
  wp_cache_add_to_buffer( $buffer, "super cache" );
591
  fputs($fr2, $buffer );
592
  }
593
  if ( isset( $gzdata ) && $gz ) {
594
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Writing gzipped buffer to supercache file." );
595
  fwrite($gz, $gzdata );
596
  }
597
  }
@@ -602,7 +602,7 @@ function wp_cache_get_ob(&$buffer) {
602
  $supercacheonly = false;
603
  fclose($fr);
604
  if ( filesize( $tmp_wpcache_filename ) == 0 ) {
605
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Warning! The file $tmp_wpcache_filename was empty. Did not rename to {$blog_cache_dir}{$cache_filename}", 5 );
606
  @unlink( $tmp_wpcache_filename );
607
  } else {
608
  if ( !@rename( $tmp_wpcache_filename, $blog_cache_dir . $cache_filename ) ) {
@@ -611,7 +611,7 @@ function wp_cache_get_ob(&$buffer) {
611
  @unlink( $blog_cache_dir . $cache_filename );
612
  @rename( $tmp_wpcache_filename, $blog_cache_dir . $cache_filename );
613
  }
614
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Renamed temp wp-cache file to {$blog_cache_dir}$cache_filename", 5 );
615
  $added_cache = 1;
616
  }
617
  }
@@ -619,31 +619,31 @@ function wp_cache_get_ob(&$buffer) {
619
  fclose($fr2);
620
  if ( $wp_cache_front_page_checks && $cache_fname == $supercachedir . $home_url[ 'path' ] . supercache_filename() && !( $wp_cache_is_home ) ) {
621
  wp_cache_writers_exit();
622
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Warning! Not writing another page to front page cache.", 1 );
623
  return $buffer;
624
  } elseif ( filesize( $tmp_cache_filename ) == 0 ) {
625
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Warning! The file $tmp_cache_filename was empty. Did not rename to {$cache_fname}", 5 );
626
  @unlink( $tmp_cache_filename );
627
  } else {
628
  if ( !@rename( $tmp_cache_filename, $cache_fname ) ) {
629
  @unlink( $cache_fname );
630
  @rename( $tmp_cache_filename, $cache_fname );
631
  }
632
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Renamed temp supercache file to $cache_fname", 5 );
633
  $added_cache = 1;
634
  }
635
  }
636
  if( $gz ) {
637
  fclose($gz);
638
  if ( filesize( $tmp_cache_filename . '.gz' ) == 0 ) {
639
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Warning! The file {$tmp_cache_filename}.gz was empty. Did not rename to {$cache_fname}.gz", 5 );
640
  @unlink( $tmp_cache_filename . '.gz' );
641
  } else {
642
  if ( !@rename( $tmp_cache_filename . '.gz', $cache_fname . '.gz' ) ) {
643
  @unlink( $cache_fname . '.gz' );
644
  @rename( $tmp_cache_filename . '.gz', $cache_fname . '.gz' );
645
  }
646
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Renamed temp supercache gz file to {$cache_fname}.gz", 5 );
647
  $added_cache = 1;
648
  }
649
  }
@@ -658,13 +658,13 @@ function wp_cache_get_ob(&$buffer) {
658
  }
659
  wp_cache_writers_exit();
660
  if ( !headers_sent() && $wp_cache_gzip_encoding && $gzdata) {
661
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Writing gzip content headers. Sending buffer to browser", 5 );
662
  header( 'Content-Encoding: ' . $wp_cache_gzip_encoding );
663
  header( 'Vary: Accept-Encoding, Cookie' );
664
  header( 'Content-Length: ' . $gzsize );
665
  return $gzdata;
666
  } else {
667
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Sending buffer to browser", 5 );
668
  return $buffer;
669
  }
670
  }
@@ -674,7 +674,7 @@ function wp_cache_phase2_clean_cache($file_prefix) {
674
 
675
  if( !wp_cache_writers_entry() )
676
  return false;
677
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Cleaning cache in $blog_cache_dir", 3 );
678
  if ( ( $handle = @opendir( $blog_cache_dir ) ) ) {
679
  while ( false !== ($file = @readdir($handle))) {
680
  if ( preg_match("/^$file_prefix/", $file) ) {
@@ -719,7 +719,7 @@ function prune_super_cache( $directory, $force = false, $rename = false ) {
719
  if ($file == '.' || $file == '..')
720
  continue;
721
  $donotdelete = true;
722
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "gc: could not delete $entry as it's not empty: $file", 2 );
723
  }
724
  closedir($handle);
725
  }
@@ -729,9 +729,9 @@ function prune_super_cache( $directory, $force = false, $rename = false ) {
729
  @rmdir( $entry );
730
  $log++;
731
  if ( $force ) {
732
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "gc: deleted $entry, forced delete", 2 );
733
  } else {
734
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "gc: deleted $entry, older than $cache_max_time seconds", 2 );
735
  }
736
  }
737
  }
@@ -743,11 +743,11 @@ function prune_super_cache( $directory, $force = false, $rename = false ) {
743
  if( in_array( $directory, $protected_directories ) )
744
  $oktodelete = false;
745
  if( $oktodelete && !$rename ) {
746
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "prune_super_cache: deleted $directory", 5 );
747
  @unlink( $directory );
748
  $log++;
749
  } elseif( $oktodelete && $rename ) {
750
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "prune_super_cache: wp_cache_rebuild_or_delete( $directory )", 5 );
751
  wp_cache_rebuild_or_delete( $directory );
752
  $log++;
753
  }
@@ -762,14 +762,14 @@ function wp_cache_rebuild_or_delete( $file ) {
762
  if( $cache_rebuild_files && substr( $file, -14 ) != '.needs-rebuild' ) {
763
  if( @rename($file, $file . '.needs-rebuild') ) {
764
  @touch( $file . '.needs-rebuild' );
765
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "rebuild_or_gc: rename to {$file}.needs-rebuild", 2 );
766
  } else {
767
  @unlink( $file );
768
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "rebuild_or_gc: deleted $file", 2 );
769
  }
770
  } else {
771
  @unlink( $file );
772
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "rebuild_or_gc: deleted $file", 2 );
773
  }
774
  }
775
 
@@ -780,28 +780,28 @@ function wp_cache_phase2_clean_expired( $file_prefix, $force = false ) {
780
  if( !wp_cache_writers_entry() )
781
  return false;
782
  $now = time();
783
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Cleaning expired cache files in $blog_cache_dir", 2 );
784
  if ( ( $handle = @opendir( $blog_cache_dir ) ) ) {
785
  while ( false !== ($file = readdir($handle))) {
786
  if ( preg_match("/^$file_prefix/", $file) &&
787
  (@filemtime( $blog_cache_dir . $file) + $cache_max_time) <= $now ) {
788
  @unlink( $blog_cache_dir . $file );
789
  @unlink( $blog_cache_dir . 'meta/' . str_replace( '.html', '.meta', $file ) );
790
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Deleting $blog_cache_dir{$file} (plus meta)", 5 );
791
  continue;
792
  }
793
  if($file != '.' && $file != '..') {
794
  if( is_dir( $blog_cache_dir . $file ) == false && (@filemtime($blog_cache_dir . $file) + $cache_max_time) <= $now ) {
795
  if( substr( $file, -9 ) != '.htaccess' ) {
796
  @unlink($blog_cache_dir . $file);
797
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Deleting $blog_cache_dir{$file}, older than $cache_max_time seconds", 5 );
798
  }
799
  }
800
  }
801
  }
802
  closedir($handle);
803
  if ( false == $wp_cache_preload_on || true == $force ) {
804
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Doing GC on supercache dir: {$cache_path}supercache", 2 );
805
  $deleted = prune_super_cache( $cache_path . 'supercache', false, false );
806
  }
807
  }
@@ -828,7 +828,7 @@ function wp_cache_shutdown_callback() {
828
  }
829
  }
830
 
831
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cache_shutdown_callback: collecting meta data.", 2 );
832
 
833
  if (!isset( $response['Last-Modified'] )) {
834
  $value = gmdate('D, d M Y H:i:s') . ' GMT';
@@ -863,21 +863,21 @@ function wp_cache_shutdown_callback() {
863
  }
864
  $value .= "; charset=\"" . $wp_cache_blog_charset . "\"";
865
 
866
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Sending 'Content-Type: $value' header.", 2 );
867
  @header("Content-Type: $value");
868
  $wp_cache_meta[ 'headers' ][ 'Content-Type' ] = "Content-Type: $value";
869
  }
870
 
871
  if ( $cache_enabled && !$supercacheonly && $new_cache ) {
872
  if( !isset( $wp_cache_meta[ 'dynamic' ] ) && $wp_cache_gzip_encoding && !in_array( 'Content-Encoding: ' . $wp_cache_gzip_encoding, $wp_cache_meta[ 'headers' ] ) ) {
873
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Sending gzip headers.", 2 );
874
  $wp_cache_meta[ 'headers' ][ 'Content-Encoding' ] = 'Content-Encoding: ' . $wp_cache_gzip_encoding;
875
  $wp_cache_meta[ 'headers' ][ 'Vary' ] = 'Vary: Accept-Encoding, Cookie';
876
  }
877
 
878
  $serial = serialize($wp_cache_meta);
879
  if( wp_cache_writers_entry() ) {
880
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Writing meta file: {$blog_cache_dir}meta/{$meta_file}", 2 );
881
  if ( false == $wp_cache_object_cache ) {
882
  $tmp_meta_filename = $blog_cache_dir . 'meta/' . uniqid( mt_rand(), true ) . '.tmp';
883
  $fr = @fopen( $tmp_meta_filename, 'w');
@@ -893,7 +893,7 @@ function wp_cache_shutdown_callback() {
893
  @rename( $tmp_meta_filename, $blog_cache_dir . 'meta/' . $meta_file );
894
  }
895
  } else {
896
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Problem writing meta file: {$blog_cache_dir}meta/{$meta_file}", 2 );
897
  }
898
  } elseif ( $cache_enabled ) {
899
  $oc_key = get_oc_key() . ".meta";
@@ -904,11 +904,11 @@ function wp_cache_shutdown_callback() {
904
  wp_cache_writers_exit();
905
  }
906
  } else {
907
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Did not write meta file: $meta_file *$supercacheonly* *$wp_cache_not_logged_in* *$new_cache*", 2 );
908
  }
909
  global $time_to_gc_cache;
910
  if( isset( $time_to_gc_cache ) && $time_to_gc_cache == 1 ) {
911
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Executing wp_cache_gc action.", 3 );
912
  do_action( 'wp_cache_gc' );
913
  }
914
  }
@@ -927,7 +927,7 @@ function wp_cache_get_postid_from_comment( $comment_id, $status = 'NA' ) {
927
 
928
  if ( ( $status == 'trash' || $status == 'spam' ) && $comment[ 'old_comment_approved' ] != 1 ) {
929
  // don't modify cache if moderated comments are trashed or spammed
930
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Moderated comment deleted or spammed. Don't delete any cache files.", 4 );
931
  define( 'DONOTDELETECACHE', 1 );
932
  return wp_cache_post_id();
933
  }
@@ -936,20 +936,20 @@ function wp_cache_get_postid_from_comment( $comment_id, $status = 'NA' ) {
936
  // http://ocaoimh.ie/2006/12/05/caching-wordpress-with-wp-cache-in-a-spam-filled-world
937
  if ( !preg_match('/wp-admin\//', $wp_cache_request_uri) ) {
938
  if ( $comment['comment_approved'] == 'delete' && ( isset( $comment[ 'old_comment_approved' ] ) && $comment[ 'old_comment_approved' ] == 0 ) ) { // do nothing if moderated comments are deleted
939
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Moderated comment deleted. Don't delete any cache files.", 4 );
940
  define( 'DONOTDELETECACHE', 1 );
941
  return $postid;
942
  } elseif ( $comment['comment_approved'] == 'spam' ) {
943
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Spam comment. Don't delete any cache files.", 4 );
944
  define( 'DONOTDELETECACHE', 1 );
945
  return $postid;
946
  } elseif( $comment['comment_approved'] == '0' ) {
947
  if ( $comment[ 'content_type' ] == '' ) {
948
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Moderated comment. Don't delete supercache file until comment approved.", 4 );
949
  $super_cache_enabled = 0; // don't remove the super cache static file until comment is approved
950
  define( 'DONOTDELETECACHE', 1 );
951
  } else {
952
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Moderated ping or trackback. Not deleting cache files..", 4 );
953
  define( 'DONOTDELETECACHE', 1 );
954
  return $postid;
955
  }
@@ -959,10 +959,10 @@ function wp_cache_get_postid_from_comment( $comment_id, $status = 'NA' ) {
959
  // for delete, for example both wp_set_comment_status and delete_comment
960
  // are called when deleting a comment
961
  if ($postid > 0) {
962
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Post $postid changed. Update cache.", 4 );
963
  return wp_cache_post_change( $postid );
964
  } elseif ( $_GET[ 'delete_all' ] != 'Empty Trash' && $_GET[ 'delete_all2' ] != 'Empty Spam' ) {
965
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Unknown post changed. Update cache.", 4 );
966
  return wp_cache_post_change( wp_cache_post_id() );
967
  }
968
  }
@@ -980,11 +980,11 @@ function wp_cache_clear_cache( $blog_id = 0 ) {
980
  reset_oc_version();
981
  } else {
982
  if ( $blog_id == 0 ) {
983
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Clearing all cached files in wp_cache_clear_cache()", 4 );
984
  prune_super_cache( $cache_path . 'supercache/', true );
985
  prune_super_cache( $cache_path, true );
986
  } else {
987
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Clearing all cached files for blog $blog_id in wp_cache_clear_cache()", 4 );
988
  prune_super_cache( get_supercache_dir( $blog_id ), true );
989
  prune_super_cache( $cache_path . 'blogs/', true );
990
  }
@@ -1001,7 +1001,7 @@ function wpsc_delete_cats_tags( $post ) {
1001
  $category_base = trailingslashit( $category_base ); // paranoid much?
1002
  foreach ($categories as $cat) {
1003
  prune_super_cache ( get_supercache_dir() . $category_base . $cat->slug . '/', true );
1004
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wpsc_post_transition: deleting category: " . get_supercache_dir() . $category_base . $cat->slug . '/' );
1005
  }
1006
  }
1007
  $posttags = get_the_tags($post->ID);
@@ -1012,7 +1012,7 @@ function wpsc_delete_cats_tags( $post ) {
1012
  $tag_base = trailingslashit( str_replace( '..', '', $tag_base ) ); // maybe!
1013
  foreach ($posttags as $tag) {
1014
  prune_super_cache( get_supercache_dir() . $tag_base . $tag->slug . '/', true );
1015
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wpsc_post_transition: deleting tag: " . get_supercache_dir() . $tag_base . $tag->slug . '/' );
1016
  }
1017
  }
1018
  }
@@ -1025,7 +1025,7 @@ function wpsc_post_transition( $new_status, $old_status, $post ) {
1025
  ) {
1026
  wpsc_delete_cats_tags( $post );
1027
  prune_super_cache( get_supercache_dir() . '/' . $post->post_name . '/', true );
1028
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wpsc_post_transition: deleting post: " . get_supercache_dir() . '/' . $post->post_name . '/' );
1029
  }
1030
  }
1031
 
@@ -1035,7 +1035,7 @@ function wp_cache_post_edit($post_id) {
1035
  static $last_post_edited = -1;
1036
 
1037
  if ( $post_id == $last_post_edited ) {
1038
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cache_post_edit: Already processed post $post_id.", 4 );
1039
  return $post_id;
1040
  }
1041
 
@@ -1046,14 +1046,14 @@ function wp_cache_post_edit($post_id) {
1046
  // Some users are inexplicibly seeing this error on scheduled posts.
1047
  // define this constant to disable the post status check.
1048
  if ( false == defined( 'WPSCFORCEUPDATE' ) && $post->post_status != 'publish' ) {
1049
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cache_post_edit: draft post, not deleting any cache files.", 4 );
1050
  return $post_id;
1051
  }
1052
 
1053
  // we want to process the post again just in case it becomes published before the second time this function is called.
1054
  $last_post_edited = $post_id;
1055
  if( $wp_cache_clear_on_post_edit ) {
1056
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cache_post_edit: Clearing cache $blog_cache_dir and {$cache_path}supercache/ on post edit per config.", 2 );
1057
  if ( $wp_cache_object_cache ) {
1058
  reset_oc_version();
1059
  } else {
@@ -1061,7 +1061,7 @@ function wp_cache_post_edit($post_id) {
1061
  prune_super_cache( get_supercache_dir(), true );
1062
  }
1063
  } else {
1064
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cache_post_edit: Clearing cache for post $post_id on post edit.", 2 );
1065
  wp_cache_post_change( $post_id );
1066
  }
1067
  }
@@ -1078,20 +1078,20 @@ function wp_cache_post_id_gc( $siteurl, $post_id, $all = 'all' ) {
1078
 
1079
  $permalink = trailingslashit( str_replace( get_option( 'home' ), '', post_permalink( $post_id ) ) );
1080
  $dir = get_current_url_supercache_dir( $post_id );
1081
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cache_post_id_gc post_id: $post_id " . post_permalink( $post_id ) . " clearing cache in $dir.", 4 );
1082
  if ( $all == 'all' ) {
1083
  prune_super_cache( $dir, true, true );
1084
  do_action( 'gc_cache', 'prune', $permalink );
1085
  @rmdir( $dir );
1086
  } else {
1087
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cache_post_id_gc clearing cached index files in $dir.", 4 );
1088
  prune_super_cache( $dir, true, true );
1089
  do_action( 'gc_cache', 'prune', $permalink );
1090
  }
1091
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cache_post_id_gc clearing cache in {$dir}/page/.", 4 );
1092
  prune_super_cache( $dir . '/page/', true );
1093
  $supercache_home = get_supercache_dir();
1094
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cache_post_id_gc clearing cache in {$supercache_home}/page/.", 4 );
1095
  prune_super_cache( $supercache_home . '/page/', true );
1096
  do_action( 'gc_cache', 'prune', '/page/' );
1097
  }
@@ -1101,14 +1101,14 @@ function wp_cache_post_change( $post_id ) {
1101
  static $last_processed = -1;
1102
 
1103
  if ( $post_id == $last_processed ) {
1104
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cache_post_change: Already processed post $post_id.", 4 );
1105
  return $post_id;
1106
  }
1107
  $post = get_post( $post_id );
1108
  // Some users are inexplicibly seeing this error on scheduled posts.
1109
  // define this constant to disable the post status check.
1110
  if ( false == defined( 'WPSCFORCEUPDATE' ) && is_object( $post ) && $post->post_status != 'publish' ) {
1111
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cache_post_change: draft post, not deleting any cache files.", 4 );
1112
  return $post_id;
1113
  }
1114
  $last_processed = $post_id;
@@ -1118,10 +1118,10 @@ function wp_cache_post_change( $post_id ) {
1118
 
1119
  if ( isset( $wp_cache_refresh_single_only ) && $wp_cache_refresh_single_only && ( strpos( $_SERVER[ 'HTTP_REFERER' ], 'edit-comments.php' ) || strpos( $_SERVER[ 'REQUEST_URI' ], 'wp-comments-post.php' ) ) ) {
1120
  if ( defined( 'DONOTDELETECACHE' ) ) {
1121
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cache_post_change: comment detected and it's moderated or spam. Not deleting cached files.", 4 );
1122
  return $post_id;
1123
  } else {
1124
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cache_post_change: comment detected. only deleting post page.", 4 );
1125
  $all = false;
1126
  }
1127
  } else {
@@ -1138,7 +1138,7 @@ function wp_cache_post_change( $post_id ) {
1138
  // make sure the front page has a rebuild file
1139
  wp_cache_post_id_gc( $siteurl, $post_id );
1140
  if ( $all == true ) {
1141
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Post change: deleting cache files in " . $cache_path . 'supercache/' . $siteurl, 4 );
1142
  $files_to_check = get_all_supercache_filenames( $dir );
1143
  foreach( $files_to_check as $cache_file ) {
1144
  prune_super_cache( $dir . $cache_file, true, true );
@@ -1146,8 +1146,8 @@ function wp_cache_post_change( $post_id ) {
1146
  do_action( 'gc_cache', 'prune', 'homepage' );
1147
  }
1148
  if( $all == true && get_option( 'show_on_front' ) == 'page' ) {
1149
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Post change: deleting page_on_front and page_for_posts pages.", 4 );
1150
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Post change: page_on_front " . get_option( 'page_on_front' ), 4 );
1151
  wp_cache_post_id_gc( $siteurl, get_option( 'page_on_front' ), 'single' );
1152
  $permalink = trailingslashit( str_replace( get_option( 'home' ), '', post_permalink( get_option( 'page_for_posts' ) ) ) );
1153
  $files_to_check = get_all_supercache_filenames( $dir . $permalink );
@@ -1166,7 +1166,7 @@ function wp_cache_post_change( $post_id ) {
1166
  $content_pathname = $blog_cache_dir . $matches[1] . ".html";
1167
  $meta = unserialize(@file_get_contents($meta_pathname));
1168
  if( false == is_array( $meta ) ) {
1169
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Post change cleaning up stray file: $content_pathname", 4 );
1170
  @unlink($meta_pathname);
1171
  @unlink($content_pathname);
1172
  continue;
@@ -1174,7 +1174,7 @@ function wp_cache_post_change( $post_id ) {
1174
  if ($post_id > 0 && $meta) {
1175
  $permalink = trailingslashit( str_replace( get_option( 'home' ), '', post_permalink( $post_id ) ) );
1176
  if ( $meta[ 'blog_id' ] == $blog_id && ( ( $all == true && !$meta[ 'post' ] ) || $meta[ 'post' ] == $post_id) ) {
1177
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Post change: deleting post cache files for {$meta[ 'uri' ]}: $content_pathname", 4 );
1178
  @unlink($meta_pathname);
1179
  @unlink($content_pathname);
1180
  if ( $super_cache_enabled == true ) {
@@ -1183,7 +1183,7 @@ function wp_cache_post_change( $post_id ) {
1183
  }
1184
  }
1185
  } elseif ($meta[ 'blog_id' ] == $blog_id) {
1186
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Post change: deleting cache files for {$meta[ 'uri' ]}: $content_pathname", 4 );
1187
  @unlink($meta_pathname);
1188
  @unlink($content_pathname);
1189
  if ( $super_cache_enabled == true ) {
@@ -1225,14 +1225,14 @@ function maybe_stop_gc( $flag ) {
1225
  if ( @file_exists( $flag ) ) {
1226
  if ( time() - filemtime( $flag ) > 3600 ) {
1227
  @unlink( $flag );
1228
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "maybe_stop_gc: GC flag found but deleted because it's older than 3600 seconds.", 5 );
1229
  return false;
1230
  } else {
1231
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'maybe_stop_gc: GC flag found. GC cancelled.', 5 );
1232
  return true;
1233
  }
1234
  } else {
1235
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'maybe_stop_gc: GC flag not found. GC will go ahead..', 5 );
1236
  return false;
1237
  }
1238
  }
@@ -1246,22 +1246,22 @@ function wp_cache_gc_cron() {
1246
 
1247
  $msg = '';
1248
  if ( $cache_max_time == 0 ) {
1249
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Cache garbage collection disabled because cache expiry time is zero.', 5 );
1250
  return false;
1251
  }
1252
 
1253
  $gc_flag = get_gc_flag();
1254
  if ( maybe_stop_gc( $gc_flag ) ) {
1255
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'GC flag found. GC cancelled.', 5 );
1256
  return false;
1257
  }
1258
 
1259
  update_option( 'wpsupercache_gc_time', time() );
1260
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cache_gc_cron: Set GC Flag. ($gc_flag)", 5 );
1261
  $fp = @fopen( $gc_flag, 'w' );
1262
  @fclose( $fp );
1263
 
1264
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Cache garbage collection.', 5 );
1265
 
1266
  if( !isset( $cache_max_time ) )
1267
  $cache_max_time = 600;
@@ -1269,12 +1269,12 @@ function wp_cache_gc_cron() {
1269
  $start = time();
1270
  $num = 0;
1271
  if( false === ( $num = wp_cache_phase2_clean_expired( $file_prefix ) ) ) {
1272
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Cache Expiry cron job failed. Probably mutex locked.', 1 );
1273
  update_option( 'wpsupercache_gc_time', time() - ( $cache_time_interval - 10 ) ); // if GC failed then run it again in one minute
1274
  $msg .= __( 'Cache expiry cron job failed. Job will run again in 10 seconds.', 'wp-super-cache' ) . "\n";
1275
  }
1276
  if( time() - $start > 30 ) {
1277
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Cache Expiry cron job took more than 30 seconds to execute.\nYou should reduce the Expiry Time in the WP Super Cache admin page\nas you probably have more cache files than your server can handle efficiently.", 1 );
1278
  $msg .= __( 'Cache expiry cron job took more than 30 seconds. You should probably run the garbage collector more often.', 'wp-super-cache' ) . "\n";
1279
  }
1280
 
@@ -1287,7 +1287,7 @@ function wp_cache_gc_cron() {
1287
  wp_mail( get_option( 'admin_email' ), sprintf( __( '[%1$s] WP Super Cache GC Report', 'wp-super-cache' ), site_url() ), $msg );
1288
  }
1289
  @unlink( $gc_flag );
1290
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'GC completed. GC flag deleted.', 5 );
1291
  schedule_wp_gc( 1 );
1292
  }
1293
 
@@ -1318,7 +1318,7 @@ function schedule_wp_gc( $forced = 0 ) {
1318
  if ( !($t = wp_next_scheduled( 'wp_cache_gc' ) ) ) {
1319
  wp_clear_scheduled_hook( 'wp_cache_gc' );
1320
  wp_schedule_single_event( time() + $cache_time_interval, 'wp_cache_gc' );
1321
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'scheduled wp_cache_gc for 10 seconds time.', 5 );
1322
  }
1323
  } else {
1324
  global $time_to_gc_cache;
@@ -1333,7 +1333,7 @@ function schedule_wp_gc( $forced = 0 ) {
1333
 
1334
  function wp_cache_gc_watcher() {
1335
  if ( false == wp_next_scheduled( 'wp_cache_gc' ) ) {
1336
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'GC Watcher: scheduled new gc cron.', 5 );
1337
  schedule_wp_gc();
1338
  }
1339
  }
6
  global $cache_enabled, $wp_cache_gmt_offset, $wp_cache_blog_charset, $cache_schedule_type, $cache_scheduled_time, $cache_schedule_interval;
7
 
8
  if ( $cache_enabled == false ) {
9
+ wp_cache_debug( "Caching disabled! quiting!", 1 );
10
  return false;
11
  }
12
 
13
+ wp_cache_debug( 'In WP Cache Phase 2', 5 );
14
 
15
  $wp_cache_gmt_offset = get_option( 'gmt_offset' ); // caching for later use when wpdb is gone. http://wordpress.org/support/topic/224349
16
  $wp_cache_blog_charset = get_option( 'blog_charset' );
17
 
18
  wp_cache_mutex_init();
19
  if(function_exists('add_action') && ( !defined( 'WPLOCKDOWN' ) || ( defined( 'WPLOCKDOWN' ) && constant( 'WPLOCKDOWN' ) == '0' ) ) ) {
20
+ wp_cache_debug( 'Setting up WordPress actions', 5 );
21
 
22
  add_action( 'template_redirect', 'wp_super_cache_query_vars' );
23
 
47
  }
48
 
49
  if ( is_admin() ) {
50
+ wp_cache_debug( 'Not caching wp-admin requests.', 5 );
51
  return false;
52
  }
53
 
54
  if ( !empty( $_GET ) ) {
55
+ wp_cache_debug( 'Supercache caching disabled. Only using wp-cache. Non empty GET request. ' . print_r( $_GET, 1 ), 5 );
56
  $super_cache_enabled = false;
57
  }
58
 
61
  else
62
  header('Vary: Cookie');
63
  ob_start( 'wp_cache_ob_callback' );
64
+ wp_cache_debug( 'Created output buffer', 4 );
65
 
66
  // restore old supercache file temporarily
67
  if( $super_cache_enabled && $cache_rebuild_files ) {
83
  continue;
84
  $mtime = @filemtime($cache_file . '.needs-rebuild');
85
  if( $mtime && (time() - $mtime) < 30 ) {
86
+ wp_cache_debug( "Rebuild file renamed to cache file temporarily: $cache_file", 3 );
87
  @rename( $cache_file . '.needs-rebuild', $cache_file );
88
  }
89
  // cleanup old files or if rename fails
90
  if( @file_exists( $cache_file . '.needs-rebuild' ) ) {
91
+ wp_cache_debug( "Rebuild file deleted: {$cache_file}.needs-rebuild", 3 );
92
  @unlink( $cache_file . '.needs-rebuild' );
93
  }
94
  }
164
  $mutex = false;
165
  if ($use_flock ) {
166
  setup_blog_cache_dir();
167
+ wp_cache_debug( "Created mutex lock on filename: {$blog_cache_dir}{$mutex_filename}", 5 );
168
  $mutex = @fopen( $blog_cache_dir . $mutex_filename, 'w' );
169
  } else {
170
+ wp_cache_debug( "Created mutex lock on semaphore: {$sem_id}", 5 );
171
  $mutex = @sem_get( $sem_id, 1, 0644 | IPC_CREAT, 1 );
172
  }
173
  }
179
  return true;
180
 
181
  if( !$mutex ) {
182
+ wp_cache_debug( "(writers entry) mutex lock not created. not caching.", 2 );
183
  return false;
184
  }
185
 
186
  if ( $use_flock ) {
187
+ wp_cache_debug( "grabbing lock using flock()", 5 );
188
  flock($mutex, LOCK_EX);
189
  } else {
190
+ wp_cache_debug( "grabbing lock using sem_acquire()", 5 );
191
  sem_acquire($mutex);
192
  }
193
 
201
  return true;
202
 
203
  if( !$mutex ) {
204
+ wp_cache_debug( "(writers exit) mutex lock not created. not caching.", 2 );
205
  return false;
206
  }
207
 
208
  if ( $use_flock ) {
209
+ wp_cache_debug( "releasing lock using flock()", 5 );
210
  flock($mutex, LOCK_UN);
211
  } else {
212
+ wp_cache_debug( "releasing lock using sem_release()", 5 );
213
  sem_release($mutex);
214
  }
215
  }
247
  // All the things that can stop a page being cached
248
  $cache_this_page = true;
249
  if ( defined( 'DONOTCACHEPAGE' ) ) {
250
+ wp_cache_debug( 'DONOTCACHEPAGE defined. Caching disabled.', 2 );
251
  $cache_this_page = false;
252
  } elseif ( $wp_cache_no_cache_for_get && false == empty( $_GET ) && false == defined( 'DOING_CRON' ) ) {
253
+ wp_cache_debug( "Non empty GET request. Caching disabled on settings page. " . print_r( $_GET, 1 ), 1 );
254
  $cache_this_page = false;
255
  } elseif ( $_SERVER["REQUEST_METHOD"] == 'POST' || !empty( $_POST ) || get_option( 'gzipcompression' ) ) {
256
+ wp_cache_debug( 'Not caching POST request.', 5 );
257
  $cache_this_page = false;
258
  } elseif ( $wp_cache_object_cache && !empty( $_GET ) ) {
259
+ wp_cache_debug( 'Not caching GET request while object cache storage enabled.', 5 );
260
  $cache_this_page = false;
261
  } elseif ( isset( $_GET[ 'preview' ] ) ) {
262
+ wp_cache_debug( 'Not caching preview post.', 2 );
263
  $cache_this_page = false;
264
  } elseif ( !in_array($script, $cache_acceptable_files) && wp_cache_is_rejected( $wp_cache_request_uri ) ) {
265
+ wp_cache_debug( 'URI rejected. Not Caching', 2 );
266
  $cache_this_page = false;
267
  } elseif ( wp_cache_user_agent_is_rejected() ) {
268
+ wp_cache_debug( "USER AGENT ({$_SERVER[ 'HTTP_USER_AGENT' ]}) rejected. Not Caching", 4 );
269
  $cache_this_page = false;
270
  } elseif ( isset( $wp_cache_pages[ 'single' ] ) && $wp_cache_pages[ 'single' ] == 1 && isset( $wp_super_cache_query[ 'is_single' ] ) ) {
271
+ wp_cache_debug( 'Not caching single post.', 2 );
272
  $cache_this_page = false;
273
  } elseif ( isset( $wp_cache_pages[ 'pages' ] ) && $wp_cache_pages[ 'pages' ] == 1 && isset( $wp_super_cache_query[ 'is_page' ] ) ) {
274
+ wp_cache_debug( 'Not caching single page.', 2 );
275
  $cache_this_page = false;
276
  } elseif ( isset( $wp_cache_pages[ 'archives' ] ) && $wp_cache_pages[ 'archives' ] == 1 && isset( $wp_super_cache_query[ 'is_archive' ] ) ) {
277
+ wp_cache_debug( 'Not caching archive page.', 2 );
278
  $cache_this_page = false;
279
  } elseif ( isset( $wp_cache_pages[ 'tag' ] ) && $wp_cache_pages[ 'tag' ] == 1 && isset( $wp_super_cache_query[ 'is_tag' ] ) ) {
280
+ wp_cache_debug( 'Not caching tag page.', 2 );
281
  $cache_this_page = false;
282
  } elseif ( isset( $wp_cache_pages[ 'category' ] ) && $wp_cache_pages[ 'category' ] == 1 && isset( $wp_super_cache_query[ 'is_category' ] ) ) {
283
+ wp_cache_debug( 'Not caching category page.', 2 );
284
  $cache_this_page = false;
285
  } elseif ( isset( $wp_cache_pages[ 'frontpage' ] ) && $wp_cache_pages[ 'frontpage' ] == 1 && isset( $wp_super_cache_query[ 'is_front_page' ] ) ) {
286
+ wp_cache_debug( 'Not caching front page.', 2 );
287
  $cache_this_page = false;
288
  } elseif ( isset( $wp_cache_pages[ 'home' ] ) && $wp_cache_pages[ 'home' ] == 1 && isset( $wp_super_cache_query[ 'is_home' ] ) ) {
289
+ wp_cache_debug( 'Not caching home page.', 2 );
290
  $cache_this_page = false;
291
  } elseif ( isset( $wp_cache_pages[ 'search' ] ) && $wp_cache_pages[ 'search' ] == 1 && isset( $wp_super_cache_query[ 'is_search' ] ) ) {
292
+ wp_cache_debug( 'Not caching search page.', 2 );
293
  $cache_this_page = false;
294
  } elseif ( isset( $wp_cache_pages[ 'author' ] ) && $wp_cache_pages[ 'author' ] == 1 && isset( $wp_super_cache_query[ 'is_author' ] ) ) {
295
+ wp_cache_debug( 'Not caching author page.', 2 );
296
  $cache_this_page = false;
297
  } elseif ( isset( $wp_cache_pages[ 'feed' ] ) && $wp_cache_pages[ 'feed' ] == 1 && isset( $wp_super_cache_query[ 'is_feed' ] ) ) {
298
+ wp_cache_debug( 'Not caching feed.', 2 );
299
  $cache_this_page = false;
300
  }
301
 
302
  if ( !isset( $wp_query ) )
303
+ wp_cache_debug( 'wp_cache_ob_callback: WARNING! $query not defined but the plugin has worked around that problem.', 4 );
304
 
305
  if ( $cache_this_page ) {
306
 
307
+ wp_cache_debug( 'Output buffer callback', 4 );
308
 
309
  $buffer = wp_cache_get_ob( $buffer );
310
  wp_cache_shutdown_callback();
351
  function wp_cache_maybe_dynamic( &$buffer ) {
352
  global $wp_cache_mfunc_enabled;
353
  if ( $wp_cache_mfunc_enabled == 1 && do_cacheaction( 'wpsc_cachedata_safety', 0 ) === 1 ) {
354
+ wp_cache_debug( 'wp_cache_maybe_dynamic: filtered $buffer through wpsc_cachedata', 4 );
355
  return do_cacheaction( 'wpsc_cachedata', $buffer ); // dynamic content for display
356
  } else {
357
+ wp_cache_debug( 'wp_cache_maybe_dynamic: returned $buffer', 4 );
358
  return $buffer;
359
  }
360
  }
400
  wp_cache_add_to_buffer( $buffer, "Page not cached by WP Super Cache. No closing HTML tag. Check your theme." );
401
  }
402
  } else {
403
+ wp_cache_debug( "robots.txt detected. Not caching.", 2 );
404
  }
405
  }
406
 
413
 
414
  if( !wp_cache_writers_entry() ) {
415
  wp_cache_add_to_buffer( $buffer, "Page not cached by WP Super Cache. Could not get mutex lock." );
416
+ wp_cache_debug( "Could not get mutex lock. Not caching.", 1 );
417
  return wp_cache_maybe_dynamic( $buffer );
418
  }
419
 
420
  if ( $wp_cache_not_logged_in && is_feed() ) {
421
+ wp_cache_debug( "Feed detected. Writing legacy cache files.", 5 );
422
  $wp_cache_not_logged_in = false;
423
  }
424
 
427
  $dir = get_current_url_supercache_dir();
428
  $supercachedir = $cache_path . 'supercache/' . preg_replace('/:.*$/', '', $home_url[ 'host' ]);
429
  if( !empty( $_GET ) || is_feed() || ( $super_cache_enabled == true && is_dir( substr( $supercachedir, 0, -1 ) . '.disabled' ) ) ) {
430
+ wp_cache_debug( "Supercache disabled: GET or feed detected or disabled by config.", 2 );
431
  $super_cache_enabled = false;
432
  }
433
 
436
  $supercacheonly = false;
437
  if( $super_cache_enabled ) {
438
  if ( wp_cache_get_cookies_values() == '' && empty( $_GET ) ) {
439
+ wp_cache_debug( "Anonymous user detected. Only creating Supercache file.", 3 );
440
  $supercacheonly = true;
441
  }
442
  }
446
  $super_cache_enabled = false;
447
  $cache_enabled = false;
448
  $cache_error = 'Not caching requests by known users. (See Advanced Settings page)';
449
+ wp_cache_debug( 'Not caching for known user.', 5 );
450
  }
451
 
452
  if ( $wp_cache_object_cache ) { // half on mode when using the object cache
460
  }
461
 
462
  if ( !$cache_enabled ) {
463
+ wp_cache_debug( 'Cache is not enabled. Sending buffer to browser.', 5 );
464
  wp_cache_writers_exit();
465
  wp_cache_add_to_buffer( $buffer, "Page not cached by WP Super Cache. Check your settings page. $cache_error" );
466
  if ( $wp_cache_mfunc_enabled == 1 ) {
481
  if ( !$supercacheonly ) {
482
  $fr = @fopen($tmp_wpcache_filename, 'w');
483
  if (!$fr) {
484
+ wp_cache_debug( "Error. Supercache could not write to " . str_replace( ABSPATH, '', $cache_path ) . $cache_filename, 1 );
485
  wp_cache_add_to_buffer( $buffer, "File not cached! Super Cache Couldn't write to: " . str_replace( ABSPATH, '', $cache_path ) . $cache_filename );
486
  wp_cache_writers_exit();
487
  return wp_cache_maybe_dynamic( $buffer );
495
  $tmp_cache_filename = $dir . uniqid( mt_rand(), true ) . '.tmp';
496
  $fr2 = @fopen( $tmp_cache_filename, 'w' );
497
  if ( !$fr2 ) {
498
+ wp_cache_debug( "Error. Supercache could not write to " . str_replace( ABSPATH, '', $tmp_cache_filename ), 1 );
499
  wp_cache_add_to_buffer( $buffer, "File not cached! Super Cache Couldn't write to: " . str_replace( ABSPATH, '', $tmp_cache_filename ) );
500
  @fclose( $fr );
501
  @unlink( $tmp_wpcache_filename );
504
  } elseif ( ( !isset( $wp_cache_mfunc_enabled ) || $wp_cache_mfunc_enabled == 0 ) && $cache_compression ) { // don't want to store compressed files if using dynamic content
505
  $gz = @fopen( $tmp_cache_filename . ".gz", 'w');
506
  if (!$gz) {
507
+ wp_cache_debug( "Error. Supercache could not write to " . str_replace( ABSPATH, '', $tmp_cache_filename ) . ".gz", 1 );
508
  wp_cache_add_to_buffer( $buffer, "File not cached! Super Cache Couldn't write to: " . str_replace( ABSPATH, '', $tmp_cache_filename ) . ".gz" );
509
  @fclose( $fr );
510
  @unlink( $tmp_wpcache_filename );
529
  */
530
  if ( $wp_cache_mfunc_enabled == 1 ) {
531
  if ( preg_match( '/<!--mclude|<!--mfunc|<!--dynamic-cached-content-->/', $buffer ) ) { //Dynamic content
532
+ wp_cache_debug( "mfunc/mclude/dynamic-cached-content tags have been retired. Please update your theme. See docs for updates." );
533
  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." );
534
  }
535
 
538
  wp_cache_add_to_buffer( $buffer, 'Super Cache dynamic page detected but late init not set. See the readme.txt for further details.' );
539
 
540
  if ( $fr ) { // legacy caching
541
+ wp_cache_debug( "Writing dynamic buffer to legacy file." );
542
  wp_cache_add_to_buffer( $buffer, "Dynamic Legacy Super Cache" );
543
  fputs( $fr, $buffer );
544
  } elseif ( isset( $fr2 ) ) { // supercache active
545
+ wp_cache_debug( "Writing dynamic buffer to supercache file." );
546
  wp_cache_add_to_buffer( $buffer, "Dynamic Super Cache" );
547
  fputs( $fr2, $buffer );
548
  } elseif ( true == $wp_cache_object_cache ) {
553
  $buffer = do_cacheaction( 'wpsc_cachedata', $buffer ); // dynamic content for display
554
 
555
  if ( $cache_compression && $wp_cache_gzip_encoding ) {
556
+ wp_cache_debug( "Gzipping dynamic buffer for display.", 5 );
557
  wp_cache_add_to_buffer( $buffer, "Compression = gzip" );
558
  $gzdata = gzencode( $buffer, 6, FORCE_GZIP );
559
  $gzsize = function_exists( 'mb_strlen' ) ? mb_strlen( $gzdata, '8bit' ) : strlen( $gzdata );
560
  }
561
  } else {
562
  if ( $gz || $wp_cache_gzip_encoding ) {
563
+ wp_cache_debug( "Gzipping buffer.", 5 );
564
  wp_cache_add_to_buffer( $buffer, "Compression = gzip" );
565
  $gzdata = gzencode( $buffer, 6, FORCE_GZIP );
566
  $gzsize = function_exists( 'mb_strlen' ) ? mb_strlen( $gzdata, '8bit' ) : strlen( $gzdata );
569
  $wp_cache_meta[ 'headers' ][ 'Vary' ] = 'Vary: Accept-Encoding, Cookie';
570
  // Return uncompressed data & store compressed for later use
571
  if ( $fr ) {
572
+ wp_cache_debug( "Writing gzipped buffer to wp-cache cache file.", 5 );
573
  fputs($fr, $gzdata);
574
  } elseif ( $cache_enabled && $wp_cache_object_cache ) {
575
  wp_cache_set( $oc_key . ".gz", $gzdata, 'supercache', $cache_max_time );
581
  wp_cache_set( $oc_key, $buffer, 'supercache', $cache_max_time );
582
  $added_cache = 1;
583
  } elseif ( $fr ) {
584
+ wp_cache_debug( "Writing non-gzipped buffer to wp-cache cache file." );
585
  fputs($fr, $buffer);
586
  }
587
  }
588
  if ( $fr2 ) {
589
+ wp_cache_debug( "Writing non-gzipped buffer to supercache file." );
590
  wp_cache_add_to_buffer( $buffer, "super cache" );
591
  fputs($fr2, $buffer );
592
  }
593
  if ( isset( $gzdata ) && $gz ) {
594
+ wp_cache_debug( "Writing gzipped buffer to supercache file." );
595
  fwrite($gz, $gzdata );
596
  }
597
  }
602
  $supercacheonly = false;
603
  fclose($fr);
604
  if ( filesize( $tmp_wpcache_filename ) == 0 ) {
605
+ wp_cache_debug( "Warning! The file $tmp_wpcache_filename was empty. Did not rename to {$blog_cache_dir}{$cache_filename}", 5 );
606
  @unlink( $tmp_wpcache_filename );
607
  } else {
608
  if ( !@rename( $tmp_wpcache_filename, $blog_cache_dir . $cache_filename ) ) {
611
  @unlink( $blog_cache_dir . $cache_filename );
612
  @rename( $tmp_wpcache_filename, $blog_cache_dir . $cache_filename );
613
  }
614
+ wp_cache_debug( "Renamed temp wp-cache file to {$blog_cache_dir}$cache_filename", 5 );
615
  $added_cache = 1;
616
  }
617
  }
619
  fclose($fr2);
620
  if ( $wp_cache_front_page_checks && $cache_fname == $supercachedir . $home_url[ 'path' ] . supercache_filename() && !( $wp_cache_is_home ) ) {
621
  wp_cache_writers_exit();
622
+ wp_cache_debug( "Warning! Not writing another page to front page cache.", 1 );
623
  return $buffer;
624
  } elseif ( filesize( $tmp_cache_filename ) == 0 ) {
625
+ wp_cache_debug( "Warning! The file $tmp_cache_filename was empty. Did not rename to {$cache_fname}", 5 );
626
  @unlink( $tmp_cache_filename );
627
  } else {
628
  if ( !@rename( $tmp_cache_filename, $cache_fname ) ) {
629
  @unlink( $cache_fname );
630
  @rename( $tmp_cache_filename, $cache_fname );
631
  }
632
+ wp_cache_debug( "Renamed temp supercache file to $cache_fname", 5 );
633
  $added_cache = 1;
634
  }
635
  }
636
  if( $gz ) {
637
  fclose($gz);
638
  if ( filesize( $tmp_cache_filename . '.gz' ) == 0 ) {
639
+ wp_cache_debug( "Warning! The file {$tmp_cache_filename}.gz was empty. Did not rename to {$cache_fname}.gz", 5 );
640
  @unlink( $tmp_cache_filename . '.gz' );
641
  } else {
642
  if ( !@rename( $tmp_cache_filename . '.gz', $cache_fname . '.gz' ) ) {
643
  @unlink( $cache_fname . '.gz' );
644
  @rename( $tmp_cache_filename . '.gz', $cache_fname . '.gz' );
645
  }
646
+ wp_cache_debug( "Renamed temp supercache gz file to {$cache_fname}.gz", 5 );
647
  $added_cache = 1;
648
  }
649
  }
658
  }
659
  wp_cache_writers_exit();
660
  if ( !headers_sent() && $wp_cache_gzip_encoding && $gzdata) {
661
+ wp_cache_debug( "Writing gzip content headers. Sending buffer to browser", 5 );
662
  header( 'Content-Encoding: ' . $wp_cache_gzip_encoding );
663
  header( 'Vary: Accept-Encoding, Cookie' );
664
  header( 'Content-Length: ' . $gzsize );
665
  return $gzdata;
666
  } else {
667
+ wp_cache_debug( "Sending buffer to browser", 5 );
668
  return $buffer;
669
  }
670
  }
674
 
675
  if( !wp_cache_writers_entry() )
676
  return false;
677
+ wp_cache_debug( "Cleaning cache in $blog_cache_dir", 3 );
678
  if ( ( $handle = @opendir( $blog_cache_dir ) ) ) {
679
  while ( false !== ($file = @readdir($handle))) {
680
  if ( preg_match("/^$file_prefix/", $file) ) {
719
  if ($file == '.' || $file == '..')
720
  continue;
721
  $donotdelete = true;
722
+ wp_cache_debug( "gc: could not delete $entry as it's not empty: $file", 2 );
723
  }
724
  closedir($handle);
725
  }
729
  @rmdir( $entry );
730
  $log++;
731
  if ( $force ) {
732
+ wp_cache_debug( "gc: deleted $entry, forced delete", 2 );
733
  } else {
734
+ wp_cache_debug( "gc: deleted $entry, older than $cache_max_time seconds", 2 );
735
  }
736
  }
737
  }
743
  if( in_array( $directory, $protected_directories ) )
744
  $oktodelete = false;
745
  if( $oktodelete && !$rename ) {
746
+ wp_cache_debug( "prune_super_cache: deleted $directory", 5 );
747
  @unlink( $directory );
748
  $log++;
749
  } elseif( $oktodelete && $rename ) {
750
+ wp_cache_debug( "prune_super_cache: wp_cache_rebuild_or_delete( $directory )", 5 );
751
  wp_cache_rebuild_or_delete( $directory );
752
  $log++;
753
  }
762
  if( $cache_rebuild_files && substr( $file, -14 ) != '.needs-rebuild' ) {
763
  if( @rename($file, $file . '.needs-rebuild') ) {
764
  @touch( $file . '.needs-rebuild' );
765
+ wp_cache_debug( "rebuild_or_gc: rename to {$file}.needs-rebuild", 2 );
766
  } else {
767
  @unlink( $file );
768
+ wp_cache_debug( "rebuild_or_gc: deleted $file", 2 );
769
  }
770
  } else {
771
  @unlink( $file );
772
+ wp_cache_debug( "rebuild_or_gc: deleted $file", 2 );
773
  }
774
  }
775
 
780
  if( !wp_cache_writers_entry() )
781
  return false;
782
  $now = time();
783
+ wp_cache_debug( "Cleaning expired cache files in $blog_cache_dir", 2 );
784
  if ( ( $handle = @opendir( $blog_cache_dir ) ) ) {
785
  while ( false !== ($file = readdir($handle))) {
786
  if ( preg_match("/^$file_prefix/", $file) &&
787
  (@filemtime( $blog_cache_dir . $file) + $cache_max_time) <= $now ) {
788
  @unlink( $blog_cache_dir . $file );
789
  @unlink( $blog_cache_dir . 'meta/' . str_replace( '.html', '.meta', $file ) );
790
+ wp_cache_debug( "Deleting $blog_cache_dir{$file} (plus meta)", 5 );
791
  continue;
792
  }
793
  if($file != '.' && $file != '..') {
794
  if( is_dir( $blog_cache_dir . $file ) == false && (@filemtime($blog_cache_dir . $file) + $cache_max_time) <= $now ) {
795
  if( substr( $file, -9 ) != '.htaccess' ) {
796
  @unlink($blog_cache_dir . $file);
797
+ wp_cache_debug( "Deleting $blog_cache_dir{$file}, older than $cache_max_time seconds", 5 );
798
  }
799
  }
800
  }
801
  }
802
  closedir($handle);
803
  if ( false == $wp_cache_preload_on || true == $force ) {
804
+ wp_cache_debug( "Doing GC on supercache dir: {$cache_path}supercache", 2 );
805
  $deleted = prune_super_cache( $cache_path . 'supercache', false, false );
806
  }
807
  }
828
  }
829
  }
830
 
831
+ wp_cache_debug( "wp_cache_shutdown_callback: collecting meta data.", 2 );
832
 
833
  if (!isset( $response['Last-Modified'] )) {
834
  $value = gmdate('D, d M Y H:i:s') . ' GMT';
863
  }
864
  $value .= "; charset=\"" . $wp_cache_blog_charset . "\"";
865
 
866
+ wp_cache_debug( "Sending 'Content-Type: $value' header.", 2 );
867
  @header("Content-Type: $value");
868
  $wp_cache_meta[ 'headers' ][ 'Content-Type' ] = "Content-Type: $value";
869
  }
870
 
871
  if ( $cache_enabled && !$supercacheonly && $new_cache ) {
872
  if( !isset( $wp_cache_meta[ 'dynamic' ] ) && $wp_cache_gzip_encoding && !in_array( 'Content-Encoding: ' . $wp_cache_gzip_encoding, $wp_cache_meta[ 'headers' ] ) ) {
873
+ wp_cache_debug( "Sending gzip headers.", 2 );
874
  $wp_cache_meta[ 'headers' ][ 'Content-Encoding' ] = 'Content-Encoding: ' . $wp_cache_gzip_encoding;
875
  $wp_cache_meta[ 'headers' ][ 'Vary' ] = 'Vary: Accept-Encoding, Cookie';
876
  }
877
 
878
  $serial = serialize($wp_cache_meta);
879
  if( wp_cache_writers_entry() ) {
880
+ wp_cache_debug( "Writing meta file: {$blog_cache_dir}meta/{$meta_file}", 2 );
881
  if ( false == $wp_cache_object_cache ) {
882
  $tmp_meta_filename = $blog_cache_dir . 'meta/' . uniqid( mt_rand(), true ) . '.tmp';
883
  $fr = @fopen( $tmp_meta_filename, 'w');
893
  @rename( $tmp_meta_filename, $blog_cache_dir . 'meta/' . $meta_file );
894
  }
895
  } else {
896
+ wp_cache_debug( "Problem writing meta file: {$blog_cache_dir}meta/{$meta_file}", 2 );
897
  }
898
  } elseif ( $cache_enabled ) {
899
  $oc_key = get_oc_key() . ".meta";
904
  wp_cache_writers_exit();
905
  }
906
  } else {
907
+ wp_cache_debug( "Did not write meta file: $meta_file *$supercacheonly* *$wp_cache_not_logged_in* *$new_cache*", 2 );
908
  }
909
  global $time_to_gc_cache;
910
  if( isset( $time_to_gc_cache ) && $time_to_gc_cache == 1 ) {
911
+ wp_cache_debug( "Executing wp_cache_gc action.", 3 );
912
  do_action( 'wp_cache_gc' );
913
  }
914
  }
927
 
928
  if ( ( $status == 'trash' || $status == 'spam' ) && $comment[ 'old_comment_approved' ] != 1 ) {
929
  // don't modify cache if moderated comments are trashed or spammed
930
+ wp_cache_debug( "Moderated comment deleted or spammed. Don't delete any cache files.", 4 );
931
  define( 'DONOTDELETECACHE', 1 );
932
  return wp_cache_post_id();
933
  }
936
  // http://ocaoimh.ie/2006/12/05/caching-wordpress-with-wp-cache-in-a-spam-filled-world
937
  if ( !preg_match('/wp-admin\//', $wp_cache_request_uri) ) {
938
  if ( $comment['comment_approved'] == 'delete' && ( isset( $comment[ 'old_comment_approved' ] ) && $comment[ 'old_comment_approved' ] == 0 ) ) { // do nothing if moderated comments are deleted
939
+ wp_cache_debug( "Moderated comment deleted. Don't delete any cache files.", 4 );
940
  define( 'DONOTDELETECACHE', 1 );
941
  return $postid;
942
  } elseif ( $comment['comment_approved'] == 'spam' ) {
943
+ wp_cache_debug( "Spam comment. Don't delete any cache files.", 4 );
944
  define( 'DONOTDELETECACHE', 1 );
945
  return $postid;
946
  } elseif( $comment['comment_approved'] == '0' ) {
947
  if ( $comment[ 'content_type' ] == '' ) {
948
+ wp_cache_debug( "Moderated comment. Don't delete supercache file until comment approved.", 4 );
949
  $super_cache_enabled = 0; // don't remove the super cache static file until comment is approved
950
  define( 'DONOTDELETECACHE', 1 );
951
  } else {
952
+ wp_cache_debug( "Moderated ping or trackback. Not deleting cache files..", 4 );
953
  define( 'DONOTDELETECACHE', 1 );
954
  return $postid;
955
  }
959
  // for delete, for example both wp_set_comment_status and delete_comment
960
  // are called when deleting a comment
961
  if ($postid > 0) {
962
+ wp_cache_debug( "Post $postid changed. Update cache.", 4 );
963
  return wp_cache_post_change( $postid );
964
  } elseif ( $_GET[ 'delete_all' ] != 'Empty Trash' && $_GET[ 'delete_all2' ] != 'Empty Spam' ) {
965
+ wp_cache_debug( "Unknown post changed. Update cache.", 4 );
966
  return wp_cache_post_change( wp_cache_post_id() );
967
  }
968
  }
980
  reset_oc_version();
981
  } else {
982
  if ( $blog_id == 0 ) {
983
+ wp_cache_debug( "Clearing all cached files in wp_cache_clear_cache()", 4 );
984
  prune_super_cache( $cache_path . 'supercache/', true );
985
  prune_super_cache( $cache_path, true );
986
  } else {
987
+ wp_cache_debug( "Clearing all cached files for blog $blog_id in wp_cache_clear_cache()", 4 );
988
  prune_super_cache( get_supercache_dir( $blog_id ), true );
989
  prune_super_cache( $cache_path . 'blogs/', true );
990
  }
1001
  $category_base = trailingslashit( $category_base ); // paranoid much?
1002
  foreach ($categories as $cat) {
1003
  prune_super_cache ( get_supercache_dir() . $category_base . $cat->slug . '/', true );
1004
+ wp_cache_debug( "wpsc_post_transition: deleting category: " . get_supercache_dir() . $category_base . $cat->slug . '/' );
1005
  }
1006
  }
1007
  $posttags = get_the_tags($post->ID);
1012
  $tag_base = trailingslashit( str_replace( '..', '', $tag_base ) ); // maybe!
1013
  foreach ($posttags as $tag) {
1014
  prune_super_cache( get_supercache_dir() . $tag_base . $tag->slug . '/', true );
1015
+ wp_cache_debug( "wpsc_post_transition: deleting tag: " . get_supercache_dir() . $tag_base . $tag->slug . '/' );
1016
  }
1017
  }
1018
  }
1025
  ) {
1026
  wpsc_delete_cats_tags( $post );
1027
  prune_super_cache( get_supercache_dir() . '/' . $post->post_name . '/', true );
1028
+ wp_cache_debug( "wpsc_post_transition: deleting post: " . get_supercache_dir() . '/' . $post->post_name . '/' );
1029
  }
1030
  }
1031
 
1035
  static $last_post_edited = -1;
1036
 
1037
  if ( $post_id == $last_post_edited ) {
1038
+ wp_cache_debug( "wp_cache_post_edit: Already processed post $post_id.", 4 );
1039
  return $post_id;
1040
  }
1041
 
1046
  // Some users are inexplicibly seeing this error on scheduled posts.
1047
  // define this constant to disable the post status check.
1048
  if ( false == defined( 'WPSCFORCEUPDATE' ) && $post->post_status != 'publish' ) {
1049
+ wp_cache_debug( "wp_cache_post_edit: draft post, not deleting any cache files.", 4 );
1050
  return $post_id;
1051
  }
1052
 
1053
  // we want to process the post again just in case it becomes published before the second time this function is called.
1054
  $last_post_edited = $post_id;
1055
  if( $wp_cache_clear_on_post_edit ) {
1056
+ wp_cache_debug( "wp_cache_post_edit: Clearing cache $blog_cache_dir and {$cache_path}supercache/ on post edit per config.", 2 );
1057
  if ( $wp_cache_object_cache ) {
1058
  reset_oc_version();
1059
  } else {
1061
  prune_super_cache( get_supercache_dir(), true );
1062
  }
1063
  } else {
1064
+ wp_cache_debug( "wp_cache_post_edit: Clearing cache for post $post_id on post edit.", 2 );
1065
  wp_cache_post_change( $post_id );
1066
  }
1067
  }
1078
 
1079
  $permalink = trailingslashit( str_replace( get_option( 'home' ), '', post_permalink( $post_id ) ) );
1080
  $dir = get_current_url_supercache_dir( $post_id );
1081
+ wp_cache_debug( "wp_cache_post_id_gc post_id: $post_id " . post_permalink( $post_id ) . " clearing cache in $dir.", 4 );
1082
  if ( $all == 'all' ) {
1083
  prune_super_cache( $dir, true, true );
1084
  do_action( 'gc_cache', 'prune', $permalink );
1085
  @rmdir( $dir );
1086
  } else {
1087
+ wp_cache_debug( "wp_cache_post_id_gc clearing cached index files in $dir.", 4 );
1088
  prune_super_cache( $dir, true, true );
1089
  do_action( 'gc_cache', 'prune', $permalink );
1090
  }
1091
+ wp_cache_debug( "wp_cache_post_id_gc clearing cache in {$dir}/page/.", 4 );
1092
  prune_super_cache( $dir . '/page/', true );
1093
  $supercache_home = get_supercache_dir();
1094
+ wp_cache_debug( "wp_cache_post_id_gc clearing cache in {$supercache_home}/page/.", 4 );
1095
  prune_super_cache( $supercache_home . '/page/', true );
1096
  do_action( 'gc_cache', 'prune', '/page/' );
1097
  }
1101
  static $last_processed = -1;
1102
 
1103
  if ( $post_id == $last_processed ) {
1104
+ wp_cache_debug( "wp_cache_post_change: Already processed post $post_id.", 4 );
1105
  return $post_id;
1106
  }
1107
  $post = get_post( $post_id );
1108
  // Some users are inexplicibly seeing this error on scheduled posts.
1109
  // define this constant to disable the post status check.
1110
  if ( false == defined( 'WPSCFORCEUPDATE' ) && is_object( $post ) && $post->post_status != 'publish' ) {
1111
+ wp_cache_debug( "wp_cache_post_change: draft post, not deleting any cache files.", 4 );
1112
  return $post_id;
1113
  }
1114
  $last_processed = $post_id;
1118
 
1119
  if ( isset( $wp_cache_refresh_single_only ) && $wp_cache_refresh_single_only && ( strpos( $_SERVER[ 'HTTP_REFERER' ], 'edit-comments.php' ) || strpos( $_SERVER[ 'REQUEST_URI' ], 'wp-comments-post.php' ) ) ) {
1120
  if ( defined( 'DONOTDELETECACHE' ) ) {
1121
+ wp_cache_debug( "wp_cache_post_change: comment detected and it's moderated or spam. Not deleting cached files.", 4 );
1122
  return $post_id;
1123
  } else {
1124
+ wp_cache_debug( "wp_cache_post_change: comment detected. only deleting post page.", 4 );
1125
  $all = false;
1126
  }
1127
  } else {
1138
  // make sure the front page has a rebuild file
1139
  wp_cache_post_id_gc( $siteurl, $post_id );
1140
  if ( $all == true ) {
1141
+ wp_cache_debug( "Post change: deleting cache files in " . $cache_path . 'supercache/' . $siteurl, 4 );
1142
  $files_to_check = get_all_supercache_filenames( $dir );
1143
  foreach( $files_to_check as $cache_file ) {
1144
  prune_super_cache( $dir . $cache_file, true, true );
1146
  do_action( 'gc_cache', 'prune', 'homepage' );
1147
  }
1148
  if( $all == true && get_option( 'show_on_front' ) == 'page' ) {
1149
+ wp_cache_debug( "Post change: deleting page_on_front and page_for_posts pages.", 4 );
1150
+ wp_cache_debug( "Post change: page_on_front " . get_option( 'page_on_front' ), 4 );
1151
  wp_cache_post_id_gc( $siteurl, get_option( 'page_on_front' ), 'single' );
1152
  $permalink = trailingslashit( str_replace( get_option( 'home' ), '', post_permalink( get_option( 'page_for_posts' ) ) ) );
1153
  $files_to_check = get_all_supercache_filenames( $dir . $permalink );
1166
  $content_pathname = $blog_cache_dir . $matches[1] . ".html";
1167
  $meta = unserialize(@file_get_contents($meta_pathname));
1168
  if( false == is_array( $meta ) ) {
1169
+ wp_cache_debug( "Post change cleaning up stray file: $content_pathname", 4 );
1170
  @unlink($meta_pathname);
1171
  @unlink($content_pathname);
1172
  continue;
1174
  if ($post_id > 0 && $meta) {
1175
  $permalink = trailingslashit( str_replace( get_option( 'home' ), '', post_permalink( $post_id ) ) );
1176
  if ( $meta[ 'blog_id' ] == $blog_id && ( ( $all == true && !$meta[ 'post' ] ) || $meta[ 'post' ] == $post_id) ) {
1177
+ wp_cache_debug( "Post change: deleting post cache files for {$meta[ 'uri' ]}: $content_pathname", 4 );
1178
  @unlink($meta_pathname);
1179
  @unlink($content_pathname);
1180
  if ( $super_cache_enabled == true ) {
1183
  }
1184
  }
1185
  } elseif ($meta[ 'blog_id' ] == $blog_id) {
1186
+ wp_cache_debug( "Post change: deleting cache files for {$meta[ 'uri' ]}: $content_pathname", 4 );
1187
  @unlink($meta_pathname);
1188
  @unlink($content_pathname);
1189
  if ( $super_cache_enabled == true ) {
1225
  if ( @file_exists( $flag ) ) {
1226
  if ( time() - filemtime( $flag ) > 3600 ) {
1227
  @unlink( $flag );
1228
+ wp_cache_debug( "maybe_stop_gc: GC flag found but deleted because it's older than 3600 seconds.", 5 );
1229
  return false;
1230
  } else {
1231
+ wp_cache_debug( 'maybe_stop_gc: GC flag found. GC cancelled.', 5 );
1232
  return true;
1233
  }
1234
  } else {
1235
+ wp_cache_debug( 'maybe_stop_gc: GC flag not found. GC will go ahead..', 5 );
1236
  return false;
1237
  }
1238
  }
1246
 
1247
  $msg = '';
1248
  if ( $cache_max_time == 0 ) {
1249
+ wp_cache_debug( 'Cache garbage collection disabled because cache expiry time is zero.', 5 );
1250
  return false;
1251
  }
1252
 
1253
  $gc_flag = get_gc_flag();
1254
  if ( maybe_stop_gc( $gc_flag ) ) {
1255
+ wp_cache_debug( 'GC flag found. GC cancelled.', 5 );
1256
  return false;
1257
  }
1258
 
1259
  update_option( 'wpsupercache_gc_time', time() );
1260
+ wp_cache_debug( "wp_cache_gc_cron: Set GC Flag. ($gc_flag)", 5 );
1261
  $fp = @fopen( $gc_flag, 'w' );
1262
  @fclose( $fp );
1263
 
1264
+ wp_cache_debug( 'Cache garbage collection.', 5 );
1265
 
1266
  if( !isset( $cache_max_time ) )
1267
  $cache_max_time = 600;
1269
  $start = time();
1270
  $num = 0;
1271
  if( false === ( $num = wp_cache_phase2_clean_expired( $file_prefix ) ) ) {
1272
+ wp_cache_debug( 'Cache Expiry cron job failed. Probably mutex locked.', 1 );
1273
  update_option( 'wpsupercache_gc_time', time() - ( $cache_time_interval - 10 ) ); // if GC failed then run it again in one minute
1274
  $msg .= __( 'Cache expiry cron job failed. Job will run again in 10 seconds.', 'wp-super-cache' ) . "\n";
1275
  }
1276
  if( time() - $start > 30 ) {
1277
+ wp_cache_debug( "Cache Expiry cron job took more than 30 seconds to execute.\nYou should reduce the Expiry Time in the WP Super Cache admin page\nas you probably have more cache files than your server can handle efficiently.", 1 );
1278
  $msg .= __( 'Cache expiry cron job took more than 30 seconds. You should probably run the garbage collector more often.', 'wp-super-cache' ) . "\n";
1279
  }
1280
 
1287
  wp_mail( get_option( 'admin_email' ), sprintf( __( '[%1$s] WP Super Cache GC Report', 'wp-super-cache' ), site_url() ), $msg );
1288
  }
1289
  @unlink( $gc_flag );
1290
+ wp_cache_debug( 'GC completed. GC flag deleted.', 5 );
1291
  schedule_wp_gc( 1 );
1292
  }
1293
 
1318
  if ( !($t = wp_next_scheduled( 'wp_cache_gc' ) ) ) {
1319
  wp_clear_scheduled_hook( 'wp_cache_gc' );
1320
  wp_schedule_single_event( time() + $cache_time_interval, 'wp_cache_gc' );
1321
+ wp_cache_debug( 'scheduled wp_cache_gc for 10 seconds time.', 5 );
1322
  }
1323
  } else {
1324
  global $time_to_gc_cache;
1333
 
1334
  function wp_cache_gc_watcher() {
1335
  if ( false == wp_next_scheduled( 'wp_cache_gc' ) ) {
1336
+ wp_cache_debug( 'GC Watcher: scheduled new gc cron.', 5 );
1337
  schedule_wp_gc();
1338
  }
1339
  }
wp-cache.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP Super Cache
4
  Plugin URI: http://wordpress.org/plugins/wp-super-cache/
5
  Description: Very fast caching plugin for WordPress.
6
- Version: 1.4.2
7
  Author: Automattic
8
  Author URI: http://automattic.com/
9
  License: GPL2+
@@ -724,7 +724,7 @@ jQuery(document).ready(function(){
724
 
725
  if ( isset( $wp_super_cache_front_page_check ) && $wp_super_cache_front_page_check == 1 && !wp_next_scheduled( 'wp_cache_check_site_hook' ) ) {
726
  wp_schedule_single_event( time() + 360 , 'wp_cache_check_site_hook' );
727
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'scheduled wp_cache_check_site_hook for 360 seconds time.', 2 );
728
  }
729
 
730
  if(isset($_REQUEST['wp_restore_config']) && $valid_nonce) {
@@ -1864,7 +1864,7 @@ function wp_cache_debug_settings() {
1864
  wp_cache_replace_line('^ *\$wp_super_cache_front_page_notification', "\$wp_super_cache_front_page_notification = '$wp_super_cache_front_page_notification';", $wp_cache_config_file);
1865
  if ( $wp_super_cache_front_page_check == 1 && !wp_next_scheduled( 'wp_cache_check_site_hook' ) ) {
1866
  wp_schedule_single_event( time() + 360 , 'wp_cache_check_site_hook' );
1867
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'scheduled wp_cache_check_site_hook for 360 seconds time.', 2 );
1868
  }
1869
  }
1870
 
@@ -2247,6 +2247,8 @@ function wp_cache_files() {
2247
  continue;
2248
  }
2249
  $meta[ 'age' ] = $age;
 
 
2250
  if ( $cache_max_time > 0 && $age > $cache_max_time ) {
2251
  $expired_list[ $age ][] = $meta;
2252
  } else {
@@ -2503,7 +2505,9 @@ function wp_cache_clean_cache( $file_prefix, $all = false ) {
2503
  prune_super_cache( $supercachedir . '.disabled', true );
2504
  }
2505
  $_POST[ 'super_cache_stats' ] = 1; // regenerate super cache stats;
2506
- } elseif ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Warning! prune_super_cache() not found in wp-cache.php', 1 );
 
 
2507
 
2508
  wp_cache_clean_legacy_files( $blog_cache_dir, $file_prefix );
2509
  wp_cache_clean_legacy_files( $cache_path, $file_prefix );
@@ -2690,7 +2694,7 @@ function wp_cache_check_site() {
2690
 
2691
  if ( !wp_next_scheduled( 'wp_cache_check_site_hook' ) ) {
2692
  wp_schedule_single_event( time() + 360 , 'wp_cache_check_site_hook' );
2693
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'scheduled wp_cache_check_site_hook for 360 seconds time.', 2 );
2694
  }
2695
  }
2696
  add_action( 'wp_cache_check_site_hook', 'wp_cache_check_site' );
@@ -2864,7 +2868,7 @@ function clear_post_supercache( $post_id ) {
2864
  if ( !function_exists( 'prune_super_cache' ) )
2865
  include_once( 'wp-cache-phase2.php' );
2866
 
2867
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "clear_post_supercache: deleting $dir/index*.html files", 2 );
2868
  $files_to_check = get_all_supercache_filenames( $dir );
2869
  foreach( $files_to_check as $cache_file ) {
2870
  prune_super_cache( $dir . $cache_file, true );
@@ -2877,17 +2881,17 @@ function wp_cron_preload_cache() {
2877
 
2878
  if ( get_option( 'preload_cache_stop' ) ) {
2879
  delete_option( 'preload_cache_stop' );
2880
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cron_preload_cache: preload cancelled", 1 );
2881
  return true;
2882
  }
2883
  $mutex = $cache_path . "preload_mutex.tmp";
2884
  sleep( 3 + mt_rand( 1, 5 ) );
2885
  if ( @file_exists( $mutex ) ) {
2886
  if ( @filemtime( $mutex ) > ( time() - 600 ) ) {
2887
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cron_preload_cache: preload mutex found and less than 600 seconds old. Aborting preload.", 1 );
2888
  return true;
2889
  } else {
2890
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cron_preload_cache: old preload mutex found and deleted. Preload continues.", 1 );
2891
  @unlink( $mutex );
2892
  }
2893
  }
@@ -2896,7 +2900,7 @@ function wp_cron_preload_cache() {
2896
 
2897
  $counter = get_option( 'preload_cache_counter' );
2898
  if ( is_array( $counter ) == false ) {
2899
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cron_preload_cache: setting up preload for the first time!", 5 );
2900
  $counter = array( 'c' => 0, 't' => time() );
2901
  update_option( 'preload_cache_counter', $counter );
2902
  }
@@ -2908,7 +2912,7 @@ function wp_cron_preload_cache() {
2908
  wp_mail( get_option( 'admin_email' ), sprintf( __( '[%1$s] Cache Preload Started', 'wp-super-cache' ), site_url(), '' ), ' ' );
2909
 
2910
  if ( $wp_cache_preload_posts == 'all' || $c < $wp_cache_preload_posts ) {
2911
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cron_preload_cache: doing taxonomy preload.", 5 );
2912
  $permalink_counter_msg = $cache_path . "preload_permalink.txt";
2913
  if ( isset( $wp_cache_preload_taxonomies ) && $wp_cache_preload_taxonomies ) {
2914
  $taxonomies = apply_filters( 'wp_cache_preload_taxonomies', array( 'post_tag' => 'tag', 'category' => 'category' ) );
@@ -2942,7 +2946,7 @@ function wp_cron_preload_cache() {
2942
  continue;
2943