← All changes
|
json-endpoints/class.wpcom-json-api-bulk-update-comments-endpoint.php
+9
-2
12.0.3
→
16.3-a.1
View file →
| @@ -2,8 +2,13 @@ | ||
| 2 | 2 | /** |
| 3 | 3 | * Endpoints: /sites/%s/comments/status |
| 4 | 4 | * /sites/%s/comments/delete |
| 5 | 5 | */ |
| 6 | + | |
| 7 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 8 | + exit( 0 ); | |
| 9 | +} | |
| 10 | + | |
| 6 | 11 | new WPCOM_JSON_API_Bulk_Update_Comments_Endpoint( |
| 7 | 12 | array( |
| 8 | 13 | 'description' => 'Update multiple comment\'s status.', |
| 9 | 14 | 'group' => 'comments', |
| @@ -67,8 +72,10 @@ | ||
| 67 | 72 | ); |
| 68 | 73 | |
| 69 | 74 | /** |
| 70 | 75 | * Bulk update comments endpoint class. |
| 76 | + * | |
| 77 | + * @phan-constructor-used-for-side-effects | |
| 71 | 78 | */ |
| 72 | 79 | class WPCOM_JSON_API_Bulk_Update_Comments_Endpoint extends WPCOM_JSON_API_Endpoint { |
| 73 | 80 | /** |
| 74 | 81 | * API callback. |
| @@ -104,9 +111,9 @@ | ||
| 104 | 111 | } else { |
| 105 | 112 | $result['results'] = $this->bulk_delete_comments( $comment_ids ); |
| 106 | 113 | } |
| 107 | 114 | } else { |
| 108 | - $status = isset( $input['status'] ) ? $input['status'] : ''; | |
| 115 | + $status = $input['status'] ?? ''; | |
| 109 | 116 | $result['results'] = $this->bulk_update_comments_status( $comment_ids, $status ); |
| 110 | 117 | } |
| 111 | 118 | |
| 112 | 119 | wp_defer_comment_counting( false ); |
| @@ -223,9 +230,9 @@ | ||
| 223 | 230 | // Core uses the `pagegen_timestamp` hidden field for this same reason. |
| 224 | 231 | $delete_time = gmdate( 'Y-m-d H:i:s' ); |
| 225 | 232 | $comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_approved = %s AND %s > comment_date_gmt", $status, $delete_time ) ); |
| 226 | 233 | |
| 227 | - if ( count( $comment_ids ) < 1 ) { | |
| 234 | + if ( ! is_countable( $comment_ids ) || array() === $comment_ids ) { | |
| 228 | 235 | return array(); |
| 229 | 236 | } |
| 230 | 237 | |
| 231 | 238 | return $this->bulk_delete_comments( $comment_ids ); |