← All changes
|
vendor/woocommerce/action-scheduler/classes/ActionScheduler_WPCommentCleaner.php
+16
-2
1.5.4
→
trunk
View file →
| @@ -65,9 +65,15 @@ | ||
| 65 | 65 | * Schedules the WP Post comment table cleanup to run in 6 months if it's not already scheduled. |
| 66 | 66 | * Attached to the migration complete hook 'action_scheduler/migration_complete'. |
| 67 | 67 | */ |
| 68 | 68 | public static function maybe_schedule_cleanup() { |
| 69 | - if ( (bool) get_comments( array( 'type' => ActionScheduler_wpCommentLogger::TYPE, 'number' => 1, 'fields' => 'ids' ) ) ) { | |
| 69 | + $args = array( | |
| 70 | + 'type' => ActionScheduler_wpCommentLogger::TYPE, | |
| 71 | + 'number' => 1, | |
| 72 | + 'fields' => 'ids', | |
| 73 | + ); | |
| 74 | + | |
| 75 | + if ( (bool) get_comments( $args ) ) { | |
| 70 | 76 | update_option( self::$has_logs_option_key, 'yes' ); |
| 71 | 77 | |
| 72 | 78 | if ( ! as_next_scheduled_action( self::$cleanup_hook ) ) { |
| 73 | 79 | as_schedule_single_action( gmdate( 'U' ) + ( 6 * MONTH_IN_SECONDS ), self::$cleanup_hook ); |
| @@ -79,9 +85,17 @@ | ||
| 79 | 85 | * Delete all action comments from the WP Comments table. |
| 80 | 86 | */ |
| 81 | 87 | public static function delete_all_action_comments() { |
| 82 | 88 | global $wpdb; |
| 83 | - $wpdb->delete( $wpdb->comments, array( 'comment_type' => ActionScheduler_wpCommentLogger::TYPE, 'comment_agent' => ActionScheduler_wpCommentLogger::AGENT ) ); | |
| 89 | + | |
| 90 | + $wpdb->delete( | |
| 91 | + $wpdb->comments, | |
| 92 | + array( | |
| 93 | + 'comment_type' => ActionScheduler_wpCommentLogger::TYPE, | |
| 94 | + 'comment_agent' => ActionScheduler_wpCommentLogger::AGENT, | |
| 95 | + ) | |
| 96 | + ); | |
| 97 | + | |
| 84 | 98 | delete_option( self::$has_logs_option_key ); |
| 85 | 99 | } |
| 86 | 100 | |
| 87 | 101 | /** |