Skip to content

Commit 4993755

Browse files
Merge pull request #14 from stephandesouza/patch-1
Fixing major issues with all commands
2 parents e4ec9c9 + 50cb8c3 commit 4993755

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

cli.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ function flush( $args = array(), $assoc_args = array() ) {
3434
WP_CLI::error('There is no post with this permalink.');
3535
}
3636
} else {
37-
global $file_prefix;
3837
wp_cache_clean_cache( $file_prefix, true );
3938
WP_CLI::success( 'Cache cleared.' );
4039
}
@@ -44,11 +43,12 @@ function flush( $args = array(), $assoc_args = array() ) {
4443
* Get the status of the cache.
4544
*/
4645
function status( $args = array(), $assoc_args = array() ) {
46+
require_once( WPCACHEHOME . '/wp-cache-phase1.php' );
47+
4748
$cache_stats = get_option( 'supercache_stats' );
4849

4950
if ( !empty( $cache_stats ) ) {
5051
if ( $cache_stats['generated'] > time() - 3600 * 24 ) {
51-
global $super_cache_enabled;
5252
WP_CLI::line( 'Cache status: ' . ($super_cache_enabled ? '%gOn%n' : '%rOff%n') );
5353
WP_CLI::line( 'Cache content on ' . date('r', $cache_stats['generated'] ) . ': ' );
5454
WP_CLI::line();
@@ -71,7 +71,7 @@ function status( $args = array(), $assoc_args = array() ) {
7171
* Enable the WP Super Cache.
7272
*/
7373
function enable( $args = array(), $assoc_args = array() ) {
74-
global $super_cache_enabled;
74+
require_once( WPCACHEHOME . '/wp-cache-phase1.php' );
7575

7676
wp_super_cache_enable();
7777

@@ -86,7 +86,7 @@ function enable( $args = array(), $assoc_args = array() ) {
8686
* Disable the WP Super Cache.
8787
*/
8888
function disable( $args = array(), $assoc_args = array() ) {
89-
global $super_cache_enabled;
89+
require_once( WPCACHEHOME . '/wp-cache-phase1.php' );
9090

9191
wp_super_cache_disable();
9292

@@ -103,11 +103,12 @@ function disable( $args = array(), $assoc_args = array() ) {
103103
* @synopsis [--status] [--cancel]
104104
*/
105105
function preload( $args = array(), $assoc_args = array() ) {
106-
global $super_cache_enabled;
106+
require_once( WPCACHEHOME . '/wp-cache-phase1.php' );
107+
107108
$preload_counter = get_option( 'preload_cache_counter' );
108109
$preloading = is_array( $preload_counter ) && $preload_counter['c'] > 0;
109110
$pending_cancel = get_option( 'preload_cache_stop' );
110-
111+
111112
// Bail early if caching or preloading is disabled
112113
if( ! $super_cache_enabled ) {
113114
WP_CLI::error( 'The WP Super Cache is not enabled.' );
@@ -137,7 +138,7 @@ function preload( $args = array(), $assoc_args = array() ) {
137138
WP_CLI::error( 'Not currently preloading.' );
138139
}
139140
}
140-
141+
141142
// Start preloading if not already in progress
142143
if ( $preloading ) {
143144
WP_CLI::warning( 'Cache preloading is already in progress.' );
@@ -158,7 +159,7 @@ function preload( $args = array(), $assoc_args = array() ) {
158159
protected function preload_status( $preload_counter, $pending_cancel ) {
159160
if ( is_array( $preload_counter ) && $preload_counter['c'] > 0 ) {
160161
WP_CLI::line( sprintf( 'Currently caching from post %d to %d.', $preload_counter[ 'c' ] - 100, $preload_counter[ 'c' ] ) );
161-
162+
162163
if ( $pending_cancel ) {
163164
WP_CLI::warning( 'Pending preload cancel. It may take up to a minute for it to cancel completely.' );
164165
}
@@ -175,4 +176,3 @@ protected function preload_status( $preload_counter, $pending_cancel ) {
175176
}
176177
}
177178
) );
178-

0 commit comments

Comments
 (0)