Skip to content

Commit

Permalink
Merge pull request #1128 from crstauf/phpcs/ActionScheduler_WPComment…
Browse files Browse the repository at this point in the history
…Cleaner.php

PHPCS: `classes/ActionScheduler_WPCommentCleaner.php`
  • Loading branch information
barryhughes authored Oct 29, 2024
2 parents ef1021e + 15e2c68 commit 068b2a0
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions classes/ActionScheduler_WPCommentCleaner.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,13 @@ public static function has_logs() {
* Attached to the migration complete hook 'action_scheduler/migration_complete'.
*/
public static function maybe_schedule_cleanup() {
if ( (bool) get_comments( array( 'type' => ActionScheduler_wpCommentLogger::TYPE, 'number' => 1, 'fields' => 'ids' ) ) ) {
$args = array(
'type' => ActionScheduler_wpCommentLogger::TYPE,
'number' => 1,
'fields' => 'ids',
);

if ( (bool) get_comments( $args ) ) {
update_option( self::$has_logs_option_key, 'yes' );

if ( ! as_next_scheduled_action( self::$cleanup_hook ) ) {
Expand All @@ -80,7 +86,15 @@ public static function maybe_schedule_cleanup() {
*/
public static function delete_all_action_comments() {
global $wpdb;
$wpdb->delete( $wpdb->comments, array( 'comment_type' => ActionScheduler_wpCommentLogger::TYPE, 'comment_agent' => ActionScheduler_wpCommentLogger::AGENT ) );

$wpdb->delete(
$wpdb->comments,
array(
'comment_type' => ActionScheduler_wpCommentLogger::TYPE,
'comment_agent' => ActionScheduler_wpCommentLogger::AGENT,
)
);

delete_option( self::$has_logs_option_key );
}

Expand Down

0 comments on commit 068b2a0

Please sign in to comment.