| @@ -3,8 +3,9 @@ | ||
| 3 | 3 | /** @noinspection PhpUndefinedFunctionInspection */ |
| 4 | 4 | /** @noinspection PhpUndefinedNamespaceInspection */ |
| 5 | 5 | /** @noinspection PhpUndefinedClassInspection */ |
| 6 | 6 | |
| 7 | +if ( ! defined( 'ABSPATH' ) ) exit; | |
| 7 | 8 | /** |
| 8 | 9 | * SQLite Object Cache plugin |
| 9 | 10 | * |
| 10 | 11 | * ## OPTIONS |
| @@ -45,9 +46,9 @@ | ||
| 45 | 46 | $msg = sprintf( |
| 46 | 47 | /* translators: 1: version for sqlite 2: version for plugin 3: igbinary --- for WP-CLI */ |
| 47 | 48 | __( 'Versions: Plugin: %2$s SQLite: %1$s igbinary: %3$s.', 'sqlite-object-cache' ), |
| 48 | 49 | $wp_object_cache->sqlite_get_version(), |
| 49 | - '1.5.1', | |
| 50 | + '1.6.2', | |
| 50 | 51 | $igbinary ); |
| 51 | 52 | } |
| 52 | 53 | |
| 53 | 54 | WP_CLI::log( $this->commentPrefix . $msg ); |
| @@ -149,14 +150,14 @@ | ||
| 149 | 150 | if ( 1 === count( $args ) ) { |
| 150 | 151 | $new_target_size = strval( $args[0] ); |
| 151 | 152 | if ( $new_target_size === $old_target_size ) { |
| 152 | 153 | /* translators: 1: new target cache size --- for WP-CLI */ |
| 153 | - $msg = __( 'Target cache size unchanged at %1$sMiB', 'sqlite_object_cache' ); | |
| 154 | + $msg = __( 'Target cache size unchanged at %1$sMiB', 'sqlite-object-cache' ); | |
| 154 | 155 | $msg = sprintf( $msg, $new_target_size ); |
| 155 | 156 | WP_CLI::log( $this->commentPrefix . $msg ); |
| 156 | 157 | } else { |
| 157 | 158 | /* translators: 1: new target cache size 2:former target cache size */ |
| 158 | - $msg = __( 'Target cache size changed from %2$sMiB to %1$sMiB', 'sqlite_object_cache' ); | |
| 159 | + $msg = __( 'Target cache size changed from %2$sMiB to %1$sMiB', 'sqlite-object-cache' ); | |
| 159 | 160 | $msg = sprintf( $msg, $new_target_size, $old_target_size ); |
| 160 | 161 | $options['target_size'] = strval( $new_target_size ); |
| 161 | 162 | update_option( 'sqlite_object_cache_settings', $options, true ); |
| 162 | 163 | WP_CLI::success( $this->commentPrefix . $msg ); |
| @@ -162,9 +163,9 @@ | ||
| 162 | 163 | WP_CLI::success( $this->commentPrefix . $msg ); |
| 163 | 164 | } |
| 164 | 165 | } else { |
| 165 | 166 | /* translators: 1: target cache size */ |
| 166 | - $msg = __( 'Target cache size is %1$sMiB', 'sqlite_object_cache' ); | |
| 167 | + $msg = __( 'Target cache size is %1$sMiB', 'sqlite-object-cache' ); | |
| 167 | 168 | $msg = sprintf( $msg, $old_target_size ); |
| 168 | 169 | WP_CLI::log( $this->commentPrefix . $msg ); |
| 169 | 170 | } |
| 170 | 171 | |
| @@ -198,14 +199,14 @@ | ||
| 198 | 199 | $new_samplerate = strval( ( $new_samplerate > 100 ) ? 100 : $new_samplerate ); |
| 199 | 200 | $new_capture = ( '0' === $new_samplerate ) ? 'off' : 'on'; |
| 200 | 201 | if ( $old_samplerate === $new_samplerate ) { |
| 201 | 202 | /* translators: 1: new sample rate 0-100 --- for WP-CLI */ |
| 202 | - $msg = __( 'Performance measurement sample rate unchanged at %1$s%%', 'sqlite_object_cache' ); | |
| 203 | + $msg = __( 'Performance measurement sample rate unchanged at %1$s%%', 'sqlite-object-cache' ); | |
| 203 | 204 | $msg = sprintf( $msg, $new_samplerate ); |
| 204 | 205 | WP_CLI::log( $this->commentPrefix . $msg ); |
| 205 | 206 | } else { |
| 206 | 207 | /* translators: 1: new rate 2:former rate --- for WP-CLI */ |
| 207 | - $msg = __( 'Performance measurement sample rate changed from %2$s%% to %1$s%%', 'sqlite_object_cache' ); | |
| 208 | + $msg = __( 'Performance measurement sample rate changed from %2$s%% to %1$s%%', 'sqlite-object-cache' ); | |
| 208 | 209 | $msg = sprintf( $msg, $new_samplerate, $old_samplerate ); |
| 209 | 210 | $options['samplerate'] = strval( $new_samplerate ); |
| 210 | 211 | $options['capture'] = $new_capture; |
| 211 | 212 | |
| @@ -214,9 +215,9 @@ | ||
| 214 | 215 | |
| 215 | 216 | } |
| 216 | 217 | } else { |
| 217 | 218 | /* translators: 1: sample rate --- for WP-CLI */ |
| 218 | - $msg = __( 'Performance measurement sample rate is %1$s%%', 'sqlite_object_cache' ); | |
| 219 | + $msg = __( 'Performance measurement sample rate is %1$s%%', 'sqlite-object-cache' ); | |
| 219 | 220 | $msg = sprintf( $msg, $old_samplerate ); |
| 220 | 221 | WP_CLI::log( $this->commentPrefix . $msg ); |
| 221 | 222 | } |
| 222 | 223 | |
| @@ -243,14 +244,14 @@ | ||
| 243 | 244 | $new_samplerate = strval( $args[0] ); |
| 244 | 245 | $new_samplerate = strval( ( $new_samplerate < 1 ) ? 1 : $new_samplerate ); |
| 245 | 246 | if ( $old_samplerate === $new_samplerate ) { |
| 246 | 247 | /* translators: 1: retention time --- for WP-CLI */ |
| 247 | - $msg = __( 'Performance measurement retention unchanged at %1$shr', 'sqlite_object_cache' ); | |
| 248 | + $msg = __( 'Performance measurement retention unchanged at %1$shr', 'sqlite-object-cache' ); | |
| 248 | 249 | $msg = sprintf( $msg, $new_samplerate ); |
| 249 | 250 | WP_CLI::log( $this->commentPrefix . $msg ); |
| 250 | 251 | } else { |
| 251 | 252 | /* translators: 1: new retention time 2:former time --- for WP-CLI */ |
| 252 | - $msg = __( 'Performance measurement retention changed from %2$shr to %1$shr', 'sqlite_object_cache' ); | |
| 253 | + $msg = __( 'Performance measurement retention changed from %2$shr to %1$shr', 'sqlite-object-cache' ); | |
| 253 | 254 | $msg = sprintf( $msg, $new_samplerate, $old_samplerate ); |
| 254 | 255 | $options['retainmeasurements'] = strval( $new_samplerate ); |
| 255 | 256 | |
| 256 | 257 | update_option( 'sqlite_object_cache_settings', $options, true ); |
| @@ -258,9 +259,9 @@ | ||
| 258 | 259 | |
| 259 | 260 | } |
| 260 | 261 | } else { |
| 261 | 262 | /* translators: 1: retention time --- for WP-CLI */ |
| 262 | - $msg = __( 'Performance measurement retention is %1$shr', 'sqlite_object_cache' ); | |
| 263 | + $msg = __( 'Performance measurement retention is %1$shr', 'sqlite-object-cache' ); | |
| 263 | 264 | $msg = sprintf( $msg, $old_samplerate ); |
| 264 | 265 | WP_CLI::log( $this->commentPrefix . $msg ); |
| 265 | 266 | } |
| 266 | 267 | |
| @@ -266,9 +267,9 @@ | ||
| 266 | 267 | |
| 267 | 268 | } |
| 268 | 269 | |
| 269 | 270 | /** |
| 270 | - * Flush the cache (delete all its entries). This briefly puts your site into maintenance mode. | |
| 271 | + * Flush the cache (delete all its entries, including all transients). This briefly puts your site into maintenance mode. | |
| 271 | 272 | */ |
| 272 | 273 | function flush( $args, $assoc_args ) { |
| 273 | 274 | global $wp_object_cache; |
| 274 | 275 | if ( method_exists( $wp_object_cache, 'flush' ) ) { |
| @@ -318,9 +319,9 @@ | ||
| 318 | 319 | $current_size = $original_size; |
| 319 | 320 | /* Skip this if the current size is small enough. */ |
| 320 | 321 | if ( $current_size <= $threshold_size ) { |
| 321 | 322 | /* translators: 1: size of cache --- For WP-CLI */ |
| 322 | - $msg = __( 'Cache contains %1$01.1fMiB, no cleanup performed', 'sqlite_object_cache' ); | |
| 323 | + $msg = __( 'Cache contains %1$01.1fMiB, no cleanup performed', 'sqlite-object-cache' ); | |
| 323 | 324 | $msg = sprintf( $msg, $original_size / ( 1024.0 * 1024.0 ) ); |
| 324 | 325 | WP_CLI::log( $this->commentPrefix . $msg ); |
| 325 | 326 | |
| 326 | 327 | return; |
| @@ -332,9 +333,9 @@ | ||
| 332 | 333 | $current_size = $wp_object_cache->sqlite_get_size(); |
| 333 | 334 | |
| 334 | 335 | if ( $current_size < $original_size ) { |
| 335 | 336 | /* translators: 1: size removed 2: size remaining */ |
| 336 | - $msg = __( '%1$01.1fMiB of expired items removed from cache, leaving %2$01.1fMiB', 'sqlite_object_cache' ); | |
| 337 | + $msg = __( '%1$01.1fMiB of expired items removed from cache, leaving %2$01.1fMiB', 'sqlite-object-cache' ); | |
| 337 | 338 | $msg = sprintf( $msg, ( $original_size - $current_size ) / ( 1024.0 * 1024.0 ), ( $current_size ) / ( 1024.0 * 1024.0 ) ); |
| 338 | 339 | WP_CLI::success( $this->commentPrefix . $msg ); |
| 339 | 340 | } |
| 340 | 341 | } |
| @@ -349,9 +350,9 @@ | ||
| 349 | 350 | $wp_object_cache->sqlite_delete_old( $target_size, $current_size ); |
| 350 | 351 | $current_size = $wp_object_cache->sqlite_get_size(); |
| 351 | 352 | if ( $current_size < $original_size ) { |
| 352 | 353 | /* translators: 1: size removed 2: size remaining --- For WP-CLI */ |
| 353 | - $msg = __( '%1$01.1fMiB of least recently updated items removed from cache, leaving %2$01.1fMiB', 'sqlite_object_cache' ); | |
| 354 | + $msg = __( '%1$01.1fMiB of least recently updated items removed from cache, leaving %2$01.1fMiB', 'sqlite-object-cache' ); | |
| 354 | 355 | $msg = sprintf( $msg, ( $original_size - $current_size ) / ( 1024.0 * 1024.0 ), ( $current_size ) / ( 1024.0 * 1024.0 ) ); |
| 355 | 356 | WP_CLI::success( $this->commentPrefix . $msg ); |
| 356 | 357 | } |
| 357 | 358 | } |
| @@ -392,9 +393,9 @@ | ||
| 392 | 393 | * @return void |
| 393 | 394 | */ |
| 394 | 395 | private function exit_maintenance_mode() { |
| 395 | 396 | $maintenanceFileName = ABSPATH . '.maintenance'; |
| 396 | - unlink( $maintenanceFileName ); | |
| 397 | + wp_delete_file( $maintenanceFileName ); | |
| 397 | 398 | } |
| 398 | 399 | |
| 399 | 400 | /** |
| 400 | 401 | * Format a UNIX timestamp using WP settings. |