| @@ -113,9 +113,9 @@ | ||
| 113 | 113 | * |
| 114 | 114 | * @param string $file File constructor. |
| 115 | 115 | * @param string $version Plugin version. |
| 116 | 116 | */ |
| 117 | - public function __construct( $file = '', $version = '1.6.5' ) { | |
| 117 | + public function __construct( $file = '', $version = '1.6.2' ) { | |
| 118 | 118 | $this->_version = $version; |
| 119 | 119 | $this->_token = 'sqlite_object_cache'; |
| 120 | 120 | |
| 121 | 121 | // Load plugin environment variables. |
| @@ -163,19 +163,16 @@ | ||
| 163 | 163 | wp_cache_flush(); |
| 164 | 164 | }, 0 ); |
| 165 | 165 | |
| 166 | 166 | |
| 167 | - /* Handle cron cache cleanup, but only on main site. */ | |
| 167 | + /* Handle cron cache cleanup */ | |
| 168 | 168 | add_action( self::CLEAN_EVENT_HOOK, array( $this, 'clean_job' ), 10, 0 ); |
| 169 | - $next_event = wp_next_scheduled( self::CLEAN_EVENT_HOOK ); | |
| 170 | - if ( false === $next_event && is_main_site() ) { | |
| 169 | + if ( ! wp_next_scheduled( self::CLEAN_EVENT_HOOK ) ) { | |
| 171 | 170 | wp_schedule_event( time() + HOUR_IN_SECONDS, 'hourly', self::CLEAN_EVENT_HOOK ); |
| 172 | - } else if (false !== $next_event && is_multisite() && ! is_main_site() ) { | |
| 173 | - wp_unschedule_event ( $next_event, self::CLEAN_EVENT_HOOK); | |
| 174 | 171 | } |
| 175 | 172 | /* Handle probabilistic non-cron cleanup, one request in 2500. */ |
| 176 | 173 | /* We don't need cryptographic-grade random numbering here. */ |
| 177 | - // phpcs:ignore WordPress.WP.AlternativeFunctions.rand_rand | |
| 174 | + // phpcs:ignore WordPress.WP.AlternativeFunctions.rand_rand | |
| 178 | 175 | if ( 1 === rand( 1, 2500 ) ) { |
| 179 | 176 | add_action( 'shutdown', function () { |
| 180 | 177 | $this->clean_job( 1.25 ); |
| 181 | 178 | }, 999, 0 ); |
| @@ -201,13 +198,8 @@ | ||
| 201 | 198 | * |
| 202 | 199 | * @return void |
| 203 | 200 | */ |
| 204 | 201 | public function clean_job( $grace_factor = 1.0 ) { |
| 205 | - $current_blogid = null; | |
| 206 | - if ( is_multisite() && ! is_main_site() ) { | |
| 207 | - $current_blogid = get_current_blog_id(); | |
| 208 | - switch_to_blog( get_main_site_id() ); | |
| 209 | - } | |
| 210 | 202 | $option = get_option( $this->_token . '_settings', array() ); |
| 211 | 203 | $target_size = empty ( $option['target_size'] ) ? 16 : $option['target_size']; |
| 212 | 204 | $target_size *= ( 1024 * 1024 ); |
| 213 | 205 | $threshold_size = (int) ( $target_size * $grace_factor ); |
| @@ -238,12 +230,8 @@ | ||
| 238 | 230 | } |
| 239 | 231 | |
| 240 | 232 | /* Delete the least-recently-updated items to get to the target size. */ |
| 241 | 233 | $wp_object_cache->sqlite_delete_old( $target_size, $current_size ); |
| 242 | - | |
| 243 | - if ( null !== $current_blogid ) { | |
| 244 | - switch_to_blog ( $current_blogid ); | |
| 245 | - } | |
| 246 | 234 | } |
| 247 | 235 | |
| 248 | 236 | /** |
| 249 | 237 | * Plugin activation hook |