Cache Enabler – WordPress Cache - Version 1.8.2

Version Description

  • Update cache size transient handling (#287)
Download this release

Release Info

Developer keycdn
Plugin Icon 128x128 Cache Enabler – WordPress Cache
Version 1.8.2
Comparing to
See all releases

Code changes from version 1.8.1 to 1.8.2

Files changed (4) hide show
  1. cache-enabler.php +1 -1
  2. constants.php +1 -1
  3. inc/cache_enabler.class.php +20 -12
  4. readme.txt +3 -0
cache-enabler.php CHANGED
@@ -6,7 +6,7 @@ Description: Simple and fast WordPress caching plugin.
6
  Author: KeyCDN
7
  Author URI: https://www.keycdn.com
8
  License: GPLv2 or later
9
- Version: 1.8.1
10
  */
11
 
12
  /*
6
  Author: KeyCDN
7
  Author URI: https://www.keycdn.com
8
  License: GPLv2 or later
9
+ Version: 1.8.2
10
  */
11
 
12
  /*
constants.php CHANGED
@@ -6,7 +6,7 @@
6
  */
7
 
8
  $cache_enabler_constants = array(
9
- 'CACHE_ENABLER_VERSION' => '1.8.1',
10
  'CACHE_ENABLER_MIN_PHP' => '5.6',
11
  'CACHE_ENABLER_MIN_WP' => '5.5',
12
  'CACHE_ENABLER_DIR' => __DIR__,
6
  */
7
 
8
  $cache_enabler_constants = array(
9
+ 'CACHE_ENABLER_VERSION' => '1.8.2',
10
  'CACHE_ENABLER_MIN_PHP' => '5.6',
11
  'CACHE_ENABLER_MIN_WP' => '5.5',
12
  'CACHE_ENABLER_DIR' => __DIR__,
inc/cache_enabler.class.php CHANGED
@@ -248,9 +248,12 @@ final class Cache_Enabler {
248
  *
249
  * This runs on the 'cache_enabler_page_cache_created',
250
  * 'cache_enabler_site_cache_cleared', and 'cache_enabler_page_cache_cleared'
251
- * actions. It keeps the 'cache_enabler_cache_size' transient up to date.
 
 
252
  *
253
- * @since 1.8.0
 
254
  *
255
  * @param string $url Site or post URL.
256
  * @param int $id Blog or post ID
@@ -264,17 +267,22 @@ final class Cache_Enabler {
264
 
265
  $current_cache_size = get_transient( 'cache_enabler_cache_size' );
266
 
267
- if ( $current_cache_size === false ) {
268
- self::get_cache_size();
269
- } else {
270
- if ( count( $index ) > 1 ) {
271
- // Prevent incorrect cache size being built just in case cache cleared index is not entire site.
272
  delete_transient( 'cache_enabler_cache_size' );
 
 
 
 
 
 
 
 
 
273
  } else {
274
- // The changed cache size is negative when the cache is cleared.
275
- $changed_cache_size = array_sum( current( $index )['versions'] );
276
- $new_cache_size = $current_cache_size + $changed_cache_size;
277
- $new_cache_size = ( $new_cache_size >= 0 ) ? $new_cache_size : 0;
278
 
279
  set_transient( 'cache_enabler_cache_size', $new_cache_size, DAY_IN_SECONDS );
280
  }
@@ -2227,7 +2235,7 @@ final class Cache_Enabler {
2227
  * Check plugin's requirements.
2228
  *
2229
  * @since 1.1.0
2230
- * @change 1.8.0
2231
  *
2232
  * @global string $wp_version WordPress version.
2233
  */
248
  *
249
  * This runs on the 'cache_enabler_page_cache_created',
250
  * 'cache_enabler_site_cache_cleared', and 'cache_enabler_page_cache_cleared'
251
+ * actions. It keeps the 'cache_enabler_cache_size' transient up to date. The
252
+ * cache index count can only be greater than 1 when the cache has been cleared,
253
+ * which can be the case for both cache cleared hooks.
254
  *
255
+ * @since 1.8.0
256
+ * @change 1.8.2
257
  *
258
  * @param string $url Site or post URL.
259
  * @param int $id Blog or post ID
267
 
268
  $current_cache_size = get_transient( 'cache_enabler_cache_size' );
269
 
270
+ if ( count( $index ) > 1 ) {
271
+ if ( $current_cache_size !== false ) {
272
+ // Prevent an incorrect cache size being built when the cache cleared index is not the entire site.
 
 
273
  delete_transient( 'cache_enabler_cache_size' );
274
+ }
275
+ } else {
276
+ // The changed cache size is negative when the cache is cleared.
277
+ $changed_cache_size = array_sum( current( $index )['versions'] );
278
+
279
+ if ( $current_cache_size === false ) {
280
+ if ( $changed_cache_size > 0 ) {
281
+ self::get_cache_size();
282
+ }
283
  } else {
284
+ $new_cache_size = $current_cache_size + $changed_cache_size;
285
+ $new_cache_size = ( $new_cache_size >= 0 ) ? $new_cache_size : 0;
 
 
286
 
287
  set_transient( 'cache_enabler_cache_size', $new_cache_size, DAY_IN_SECONDS );
288
  }
2235
  * Check plugin's requirements.
2236
  *
2237
  * @since 1.1.0
2238
+ * @change 1.8.1
2239
  *
2240
  * @global string $wp_version WordPress version.
2241
  */
readme.txt CHANGED
@@ -55,6 +55,9 @@ Cache Enabler captures page contents and saves it as a static HTML file on the s
55
 
56
  == Changelog ==
57
 
 
 
 
58
  = 1.8.1 =
59
  * Fix requirements check (#285)
60
 
55
 
56
  == Changelog ==
57
 
58
+ = 1.8.2 =
59
+ * Update cache size transient handling (#287)
60
+
61
  = 1.8.1 =
62
  * Fix requirements check (#285)
63