Skip to content

Commit 31e9d08

Browse files
committed
Merge branch 'master' of https://github.com/BoldGrid/w3-total-cache into release-2.8.5
2 parents 57f1399 + 6849515 commit 31e9d08

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

Cli.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -563,17 +563,13 @@ public function pgcache_prime( array $args = array(), array $vars = array() ) {
563563
public function alwayscached_process() {
564564
if ( ! Extension_AlwaysCached_Plugin::is_enabled() ) {
565565
\WP_CLI::error(
566-
\sprintf(
567-
// translators: 1: Error message.
568-
\__( 'Always Cached feature is not enabled: %1$s', 'w3-total-cache' ),
569-
$e->getMessage()
570-
)
566+
\__( 'Always Cached feature is not enabled.', 'w3-total-cache' )
571567
);
572568
return;
573569
}
574570

575571
try {
576-
Extension_AlwaysCached_Worker::run();
572+
Extension_AlwaysCached_Worker::run( false );
577573
} catch ( \Exception $e ) {
578574
\WP_CLI::error(
579575
\sprintf(
@@ -593,11 +589,7 @@ public function alwayscached_process() {
593589
public function alwayscached_clear() {
594590
if ( ! Extension_AlwaysCached_Plugin::is_enabled() ) {
595591
\WP_CLI::error(
596-
\sprintf(
597-
// translators: 1: Error message.
598-
\__( 'Always Cached feature is not enabled: %1$s', 'w3-total-cache' ),
599-
$e->getMessage()
600-
)
592+
\__( 'Always Cached feature is not enabled', 'w3-total-cache' )
601593
);
602594
return;
603595
}

Extension_AlwaysCached_Worker.php

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ class Extension_AlwaysCached_Worker {
2323
*
2424
* @since 2.8.0
2525
*
26+
* @param bool $html Print HTML.
27+
*
2628
* @return void
2729
*/
28-
public static function run() {
30+
public static function run( $html = true ) {
2931
$timeslot_seconds = 60;
3032
$timeslot_seconds = apply_filters(
3133
'w3tc_alwayscached_worker_timeslot',
@@ -34,26 +36,30 @@ public static function run() {
3436

3537
$time_exit = time() + $timeslot_seconds;
3638

37-
echo '<div style="white-space: pre-line;">';
39+
if ( $html ) {
40+
echo '<div style="white-space: pre-line;">';
41+
}
3842

39-
esc_html_e( "Processing queue.\n", 'w3-total-cache' );
43+
esc_html_e( 'Processing queue.', 'w3-total-cache' );
4044

41-
for ( ; ; ) {
45+
// Infinite loop to process queue items until the time slot is exhausted or the queue is empty.
46+
while ( true ) {
4247
if ( time() >= $time_exit ) {
43-
esc_html_e( "\n\nQueue worker time slot exhaused.", 'w3-total-cache' );
48+
esc_html_e( "\nQueue worker time slot exhaused.", 'w3-total-cache' );
4449
break;
4550
}
4651

4752
$item = Extension_AlwaysCached_Queue::pop_item_begin();
4853

4954
if ( empty( $item ) ) {
50-
esc_html_e( "\n\nQueue is empty.", 'w3-total-cache' );
55+
esc_html_e( "\nQueue is empty.", 'w3-total-cache' );
5156
break;
5257
}
5358

5459
echo esc_html( sprintf( "\n%s ", $item['key'] ) );
5560

5661
$result = self::process_item( $item );
62+
5763
if ( 'ok' === $result ) {
5864
esc_html_e( 'ok', 'w3-total-cache' );
5965
Extension_AlwaysCached_Queue::pop_item_finish( $item );
@@ -65,7 +71,11 @@ public static function run() {
6571
}
6672
}
6773

68-
echo "\n</div>\n";
74+
if ( $html ) {
75+
echo "\n</div>\n";
76+
} else {
77+
echo "\n";
78+
}
6979
}
7080

7181
/**

0 commit comments

Comments
 (0)