Skip to content

Commit 804f66c

Browse files
committed
Merge branch 'trunk' into fix-forum-17945942
# Conflicts: # classes/ActionScheduler_WPCommentCleaner.php
2 parents 3222b69 + 375ac38 commit 804f66c

6 files changed

+222
-80
lines changed

classes/ActionScheduler_WPCommentCleaner.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,13 @@ public static function has_logs() {
6868
public static function maybe_schedule_cleanup() {
6969
$has_logs = 'no';
7070

71-
if ( (bool) get_comments( array( 'type' => ActionScheduler_wpCommentLogger::TYPE, 'number' => 1, 'fields' => 'ids' ) ) ) {
71+
$args = array(
72+
'type' => ActionScheduler_wpCommentLogger::TYPE,
73+
'number' => 1,
74+
'fields' => 'ids',
75+
);
76+
77+
if ( (bool) get_comments( $args ) ) {
7278
$has_logs = 'yes';
7379

7480
if ( ! as_next_scheduled_action( self::$cleanup_hook ) ) {
@@ -84,7 +90,15 @@ public static function maybe_schedule_cleanup() {
8490
*/
8591
public static function delete_all_action_comments() {
8692
global $wpdb;
87-
$wpdb->delete( $wpdb->comments, array( 'comment_type' => ActionScheduler_wpCommentLogger::TYPE, 'comment_agent' => ActionScheduler_wpCommentLogger::AGENT ) );
93+
94+
$wpdb->delete(
95+
$wpdb->comments,
96+
array(
97+
'comment_type' => ActionScheduler_wpCommentLogger::TYPE,
98+
'comment_agent' => ActionScheduler_wpCommentLogger::AGENT,
99+
)
100+
);
101+
88102
update_option( self::$has_logs_option_key, 'no', true );
89103
}
90104

classes/WP_CLI/ActionScheduler_WPCLI_Clean_Command.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function clean( $args, $assoc_args ) {
4141

4242
$batches_completed = 0;
4343
$actions_deleted = 0;
44-
$unlimited = $batches === 0;
44+
$unlimited = 0 === $batches;
4545
try {
4646
$lifespan = as_get_datetime_object( $before );
4747
} catch ( Exception $e ) {
@@ -58,7 +58,7 @@ public function clean( $args, $assoc_args ) {
5858
sleep( $sleep );
5959
}
6060

61-
$deleted = count( $cleaner->clean_actions( $status, $lifespan, null,'CLI' ) );
61+
$deleted = count( $cleaner->clean_actions( $status, $lifespan, null, 'CLI' ) );
6262
if ( $deleted <= 0 ) {
6363
break;
6464
}
@@ -95,8 +95,6 @@ protected function print_total_batches( int $batches_processed ) {
9595
* Convert an exception into a WP CLI error.
9696
*
9797
* @param Exception $e The error object.
98-
*
99-
* @throws \WP_CLI\ExitException
10098
*/
10199
protected function print_error( Exception $e ) {
102100
WP_CLI::error(

classes/actions/ActionScheduler_Action.php

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,32 @@
44
* Class ActionScheduler_Action
55
*/
66
class ActionScheduler_Action {
7-
/** @var string */
7+
/**
8+
* Action's hook.
9+
*
10+
* @var string
11+
*/
812
protected $hook = '';
9-
/** @var array<string, mixed> */
13+
14+
/**
15+
* Action's args.
16+
*
17+
* @var array<string, mixed>
18+
*/
1019
protected $args = array();
11-
/** @var ActionScheduler_Schedule */
12-
protected $schedule = NULL;
13-
/** @var string */
20+
21+
/**
22+
* Action's schedule.
23+
*
24+
* @var ActionScheduler_Schedule
25+
*/
26+
protected $schedule = null;
27+
28+
/**
29+
* Action's group.
30+
*
31+
* @var string
32+
*/
1433
protected $group = '';
1534

1635
/**
@@ -34,12 +53,12 @@ class ActionScheduler_Action {
3453
* @param null|ActionScheduler_Schedule $schedule Action's schedule.
3554
* @param string $group Action's group.
3655
*/
37-
public function __construct( $hook, array $args = array(), ActionScheduler_Schedule $schedule = NULL, $group = '' ) {
56+
public function __construct( $hook, array $args = array(), ActionScheduler_Schedule $schedule = null, $group = '' ) {
3857
$schedule = empty( $schedule ) ? new ActionScheduler_NullSchedule() : $schedule;
39-
$this->set_hook($hook);
40-
$this->set_schedule($schedule);
41-
$this->set_args($args);
42-
$this->set_group($group);
58+
$this->set_hook( $hook );
59+
$this->set_schedule( $schedule );
60+
$this->set_args( $args );
61+
$this->set_group( $group );
4362
}
4463

4564
/**
@@ -93,6 +112,8 @@ protected function set_schedule( ActionScheduler_Schedule $schedule ) {
93112
}
94113

95114
/**
115+
* Action's schedule.
116+
*
96117
* @return ActionScheduler_Schedule
97118
*/
98119
public function get_schedule() {
@@ -125,17 +146,21 @@ protected function set_group( $group ) {
125146
}
126147

127148
/**
149+
* Action's group.
150+
*
128151
* @return string
129152
*/
130153
public function get_group() {
131154
return $this->group;
132155
}
133156

134157
/**
135-
* @return bool If the action has been finished
158+
* Action has not finished.
159+
*
160+
* @return bool
136161
*/
137162
public function is_finished() {
138-
return FALSE;
163+
return false;
139164
}
140165

141166
/**

classes/actions/ActionScheduler_FinishedAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ public function execute() {
1616
* Get finished state.
1717
*/
1818
public function is_finished() {
19-
return TRUE;
19+
return true;
2020
}
2121
}

classes/actions/ActionScheduler_NullAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class ActionScheduler_NullAction extends ActionScheduler_Action {
1212
* @param mixed[] $args Action arguments.
1313
* @param null|ActionScheduler_Schedule $schedule Action schedule.
1414
*/
15-
public function __construct( $hook = '', array $args = array(), ActionScheduler_Schedule $schedule = NULL ) {
15+
public function __construct( $hook = '', array $args = array(), ActionScheduler_Schedule $schedule = null ) {
1616
$this->set_schedule( new ActionScheduler_NullSchedule() );
1717
}
1818

0 commit comments

Comments
 (0)