Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
22.94% covered (danger)
22.94%
39 / 170
14.29% covered (danger)
14.29%
4 / 28
CRAP
0.00% covered (danger)
0.00%
0 / 1
Comments
22.62% covered (danger)
22.62%
38 / 168
14.29% covered (danger)
14.29%
4 / 28
1509.04
0.00% covered (danger)
0.00%
0 / 1
 name
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 id_field
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 table_name
n/a
0 / 0
n/a
0 / 0
1
 table
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 get_object_by_id
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
12
 init_listeners
100.00% covered (success)
100.00%
35 / 35
100.00% covered (success)
100.00%
1 / 1
3
 handle_comment_contents_modification
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 1
20
 init_full_sync_listeners
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 get_whitelisted_comment_types
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 get_whitelisted_comment_types_sql
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 only_allow_white_listed_comment_types
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 1
30
 filter_blacklisted_post_types
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
12
 only_allow_white_listed_comment_type_transitions
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
6
 filter_jetpack_sync_before_enqueue_wp_insert_comment
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
 is_comment_type_allowed
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
6
 init_before_send
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
6
 enqueue_full_sync_actions
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 estimate_full_sync_actions
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
6
 get_where_sql
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
12
 get_full_sync_actions
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 count_full_sync_actions
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 expand_wp_comment_status_change
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 expand_wp_insert_comment
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 filter_comment
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
6
 is_whitelisted_comment_meta
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 filter_meta
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
30
 expand_comment_ids
0.00% covered (danger)
0.00%
0 / 14
0.00% covered (danger)
0.00%
0 / 1
2
 extract_comments_and_meta
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
2
 get_next_chunk
0.00% covered (danger)
0.00%
0 / 30
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2/**
3 * Comments sync module.
4 *
5 * @package automattic/jetpack-sync
6 */
7
8namespace Automattic\Jetpack\Sync\Modules;
9
10use Automattic\Jetpack\Sync\Defaults;
11use Automattic\Jetpack\Sync\Modules;
12use Automattic\Jetpack\Sync\Settings;
13
14if ( ! defined( 'ABSPATH' ) ) {
15    exit( 0 );
16}
17
18/**
19 * Class to handle sync for comments.
20 */
21class Comments extends Module {
22
23    /**
24     * Sync module name.
25     *
26     * @access public
27     *
28     * @return string
29     */
30    public function name() {
31        return 'comments';
32    }
33
34    /**
35     * The id field in the database.
36     *
37     * @access public
38     *
39     * @return string
40     */
41    public function id_field() {
42        return 'comment_ID';
43    }
44
45    /**
46     * The table name.
47     *
48     * @access public
49     *
50     * @return string
51     * @deprecated since 3.11.0 Use table() instead.
52     */
53    public function table_name() {
54        _deprecated_function( __METHOD__, '3.11.0', 'Automattic\\Jetpack\\Sync\\Comments->table' );
55        return 'comments';
56    }
57
58    /**
59     * The table in the database with the prefix.
60     *
61     * @access public
62     *
63     * @return string|bool
64     */
65    public function table() {
66        global $wpdb;
67        return $wpdb->comments;
68    }
69
70    /**
71     * Retrieve a comment by its ID.
72     *
73     * @access public
74     *
75     * @param string $object_type Type of the sync object.
76     * @param int    $id          ID of the sync object.
77     * @return \WP_Comment|bool Filtered \WP_Comment object, or false if the object is not a comment.
78     */
79    public function get_object_by_id( $object_type, $id ) {
80        $comment_id = (int) $id;
81        if ( 'comment' === $object_type ) {
82            $comment = get_comment( $comment_id );
83            if ( $comment ) {
84                return $this->filter_comment( $comment );
85            }
86        }
87
88        return false;
89    }
90
91    /**
92     * Initialize comments action listeners.
93     * Also responsible for initializing comment meta listeners.
94     *
95     * @access public
96     *
97     * @param callable $callable Action handler callable.
98     */
99    public function init_listeners( $callable ) {
100        add_action( 'wp_insert_comment', $callable, 10, 2 );
101        add_action( 'deleted_comment', $callable );
102        add_action( 'trashed_comment', $callable );
103        add_action( 'spammed_comment', $callable );
104        add_action( 'trashed_post_comments', $callable, 10, 2 );
105        add_action( 'untrash_post_comments', $callable );
106        add_action( 'comment_approved_to_unapproved', $callable );
107        add_action( 'comment_unapproved_to_approved', $callable );
108        add_action( 'jetpack_modified_comment_contents', $callable, 10, 2 );
109        add_action( 'untrashed_comment', $callable, 10, 2 );
110        add_action( 'unspammed_comment', $callable, 10, 2 );
111        add_filter( 'wp_update_comment_data', array( $this, 'handle_comment_contents_modification' ), 10, 3 );
112
113        // comment actions.
114        add_filter( 'jetpack_sync_before_enqueue_wp_insert_comment', array( $this, 'filter_jetpack_sync_before_enqueue_wp_insert_comment' ) );
115        add_filter( 'jetpack_sync_before_enqueue_deleted_comment', array( $this, 'only_allow_white_listed_comment_types' ) );
116        add_filter( 'jetpack_sync_before_enqueue_trashed_comment', array( $this, 'only_allow_white_listed_comment_types' ) );
117        add_filter( 'jetpack_sync_before_enqueue_untrashed_comment', array( $this, 'only_allow_white_listed_comment_types' ) );
118        add_filter( 'jetpack_sync_before_enqueue_spammed_comment', array( $this, 'only_allow_white_listed_comment_types' ) );
119        add_filter( 'jetpack_sync_before_enqueue_unspammed_comment', array( $this, 'only_allow_white_listed_comment_types' ) );
120
121        // comment status transitions.
122        add_filter( 'jetpack_sync_before_enqueue_comment_approved_to_unapproved', array( $this, 'only_allow_white_listed_comment_type_transitions' ) );
123        add_filter( 'jetpack_sync_before_enqueue_comment_unapproved_to_approved', array( $this, 'only_allow_white_listed_comment_type_transitions' ) );
124
125        // Post Actions.
126        add_filter( 'jetpack_sync_before_enqueue_trashed_post_comments', array( $this, 'filter_blacklisted_post_types' ) );
127        add_filter( 'jetpack_sync_before_enqueue_untrash_post_comments', array( $this, 'filter_blacklisted_post_types' ) );
128
129        /**
130         * Even though it's messy, we implement these hooks because
131         * the edit_comment hook doesn't include the data
132         * so this saves us a DB read for every comment event.
133         */
134        foreach ( $this->get_whitelisted_comment_types() as $comment_type ) {
135            foreach ( array( 'unapproved', 'approved' ) as $comment_status ) {
136                $comment_action_name = "comment_{$comment_status}_{$comment_type}";
137                add_action( $comment_action_name, $callable, 10, 2 );
138                add_filter(
139                    'jetpack_sync_before_enqueue_' . $comment_action_name,
140                    array(
141                        $this,
142                        'expand_wp_insert_comment',
143                    )
144                );
145            }
146        }
147
148        // Listen for meta changes.
149        $this->init_listeners_for_meta_type( 'comment', $callable );
150        $this->init_meta_whitelist_handler( 'comment', array( $this, 'filter_meta' ) );
151    }
152
153    /**
154     * Handler for any comment content updates.
155     *
156     * @access public
157     *
158     * @param array $new_comment              The new, processed comment data.
159     * @param array $old_comment              The old, unslashed comment data.
160     * @param array $new_comment_with_slashes The new, raw comment data.
161     * @return array The new, processed comment data.
162     */
163    public function handle_comment_contents_modification( $new_comment, $old_comment, $new_comment_with_slashes ) {
164        $changes        = array();
165        $content_fields = array(
166            'comment_author',
167            'comment_author_email',
168            'comment_author_url',
169            'comment_content',
170        );
171        foreach ( $content_fields as $field ) {
172            if ( $new_comment_with_slashes[ $field ] !== $old_comment[ $field ] ) {
173                $changes[ $field ] = array( $new_comment[ $field ], $old_comment[ $field ] );
174            }
175        }
176
177        if ( ! empty( $changes ) ) {
178            /**
179             * Signals to the sync listener that this comment's contents were modified and a sync action
180             * reflecting the change(s) to the content should be sent
181             *
182             * @since 1.6.3
183             * @since-jetpack 4.9.0
184             *
185             * @param int $new_comment['comment_ID'] ID of comment whose content was modified
186             * @param mixed $changes Array of changed comment fields with before and after values
187             */
188            do_action( 'jetpack_modified_comment_contents', $new_comment['comment_ID'], $changes );
189        }
190        return $new_comment;
191    }
192
193    /**
194     * Initialize comments action listeners for full sync.
195     *
196     * @access public
197     *
198     * @param callable $callable Action handler callable.
199     */
200    public function init_full_sync_listeners( $callable ) {
201        add_action( 'jetpack_full_sync_comments', $callable ); // Also send comments meta.
202    }
203
204    /**
205     * Gets a filtered list of comment types that sync can hook into.
206     *
207     * @access public
208     *
209     * @return array Defaults to [ '', 'comment', 'trackback', 'pingback', 'review', 'note' ].
210     */
211    public function get_whitelisted_comment_types() {
212        return Defaults::get_comment_types_whitelist();
213    }
214
215    /**
216     * Returns escaped SQL for whitelisted comment types.
217     * Can be injected directly into a WHERE clause.
218     *
219     * @access public
220     *
221     * @return string SQL WHERE clause.
222     */
223    public function get_whitelisted_comment_types_sql() {
224        return 'comment_type IN (\'' . implode( '\', \'', array_map( 'esc_sql', $this->get_whitelisted_comment_types() ) ) . '\')';
225    }
226
227    /**
228     * Prevents any comment types that are not in the whitelist from being enqueued and sent to WordPress.com.
229     *
230     * @param array $args Arguments passed to wp_insert_comment, deleted_comment, spammed_comment, etc.
231     *
232     * @return bool or array $args Arguments passed to wp_insert_comment, deleted_comment, spammed_comment, etc.
233     */
234    public function only_allow_white_listed_comment_types( $args ) {
235        $comment = false;
236
237        if ( isset( $args[1] ) ) {
238            // comment object is available.
239            $comment = $args[1];
240        } elseif ( is_numeric( $args[0] ) ) {
241            // comment_id is available.
242            $comment = get_comment( $args[0] );
243        }
244
245        if (
246            isset( $comment->comment_type )
247            && ! in_array( $comment->comment_type, $this->get_whitelisted_comment_types(), true )
248        ) {
249            return false;
250        }
251
252        return $args;
253    }
254
255    /**
256     * Filter all blacklisted post types.
257     *
258     * @param array $args Hook arguments.
259     * @return array|false Hook arguments, or false if the post type is a blacklisted one.
260     */
261    public function filter_blacklisted_post_types( $args ) {
262        $post_id      = $args[0];
263        $posts_module = Modules::get_module( 'posts' );
264        '@phan-var Posts $posts_module';
265
266        if ( false !== $posts_module && ! $posts_module->is_post_type_allowed( $post_id ) ) {
267            return false;
268        }
269
270        return $args;
271    }
272
273    /**
274     * Prevents any comment types that are not in the whitelist from being enqueued and sent to WordPress.com.
275     *
276     * @param array $args Arguments passed to wp_{old_status}_to_{new_status}.
277     *
278     * @return bool or array $args Arguments passed to wp_{old_status}_to_{new_status}
279     */
280    public function only_allow_white_listed_comment_type_transitions( $args ) {
281        $comment = $args[0];
282
283        if ( ! in_array( $comment->comment_type, $this->get_whitelisted_comment_types(), true ) ) {
284            return false;
285        }
286
287        return $args;
288    }
289
290    /**
291     * Prevents any comment types that are not in the whitelist from being enqueued and sent to WordPress.com.
292     * Also expands comment data before being enqueued.
293     *
294     * @param array $args Arguments passed to wp_insert_comment.
295     *
296     * @return false or array $args Arguments passed to wp_insert_comment or false if the comment type is a blacklisted one.
297     */
298    public function filter_jetpack_sync_before_enqueue_wp_insert_comment( $args ) {
299        if ( false === $this->only_allow_white_listed_comment_types( $args ) ) {
300            return false;
301        }
302
303        return $this->expand_wp_insert_comment( $args );
304    }
305
306    /**
307     * Whether a comment type is allowed.
308     * A comment type is allowed if it's present in the comment type whitelist.
309     *
310     * @param int $comment_id ID of the comment.
311     * @return boolean Whether the comment type is allowed.
312     */
313    public function is_comment_type_allowed( $comment_id ) {
314        $comment = get_comment( $comment_id );
315
316        if ( isset( $comment->comment_type ) ) {
317            return in_array( $comment->comment_type, $this->get_whitelisted_comment_types(), true );
318        }
319        return false;
320    }
321
322    /**
323     * Initialize the module in the sender.
324     *
325     * @access public
326     */
327    public function init_before_send() {
328
329        // Full sync.
330        $sync_module = Modules::get_module( 'full-sync' );
331        if ( $sync_module instanceof Full_Sync_Immediately ) {
332            add_filter( 'jetpack_sync_before_send_jetpack_full_sync_comments', array( $this, 'extract_comments_and_meta' ) );
333        } else {
334            add_filter( 'jetpack_sync_before_send_jetpack_full_sync_comments', array( $this, 'expand_comment_ids' ) );
335        }
336    }
337
338    /**
339     * Enqueue the comments actions for full sync.
340     *
341     * @access public
342     *
343     * @param array   $config               Full sync configuration for this sync module.
344     * @param int     $max_items_to_enqueue Maximum number of items to enqueue.
345     * @param boolean $state                True if full sync has finished enqueueing this module, false otherwise.
346     * @return array Number of actions enqueued, and next module state.
347     */
348    public function enqueue_full_sync_actions( $config, $max_items_to_enqueue, $state ) {
349        global $wpdb;
350        return $this->enqueue_all_ids_as_action( 'jetpack_full_sync_comments', $wpdb->comments, 'comment_ID', $this->get_where_sql( $config ), $max_items_to_enqueue, $state );
351    }
352
353    /**
354     * Retrieve an estimated number of actions that will be enqueued.
355     *
356     * @access public
357     *
358     * @param array $config Full sync configuration for this sync module.
359     * @return int Number of items yet to be enqueued.
360     */
361    public function estimate_full_sync_actions( $config ) {
362        global $wpdb;
363
364        $query = "SELECT count(*) FROM $wpdb->comments";
365
366        $where_sql = $this->get_where_sql( $config );
367        if ( $where_sql ) {
368            $query .= ' WHERE ' . $where_sql;
369        }
370
371        // TODO: Call $wpdb->prepare on the following query.
372        // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching
373        $count = (int) $wpdb->get_var( $query );
374
375        return (int) ceil( $count / self::ARRAY_CHUNK_SIZE );
376    }
377
378    /**
379     * Retrieve the WHERE SQL clause based on the module config.
380     *
381     * @access public
382     *
383     * @param array $config Full sync configuration for this sync module.
384     * @return string WHERE SQL clause, or `null` if no comments are specified in the module config.
385     */
386    public function get_where_sql( $config ) {
387        $where_sql = $this->get_whitelisted_comment_types_sql();
388
389        if ( is_array( $config ) && ! empty( $config ) ) {
390            return 'comment_ID IN (' . implode( ',', array_map( 'intval', $config ) ) . ')';
391        }
392
393        return $where_sql;
394    }
395
396    /**
397     * Retrieve the actions that will be sent for this module during a full sync.
398     *
399     * @access public
400     *
401     * @return array Full sync actions of this module.
402     */
403    public function get_full_sync_actions() {
404        return array( 'jetpack_full_sync_comments' );
405    }
406
407    /**
408     * Count all the actions that are going to be sent.
409     *
410     * @access public
411     *
412     * @param array $action_names Names of all the actions that will be sent.
413     * @return int Number of actions.
414     */
415    public function count_full_sync_actions( $action_names ) {
416        return $this->count_actions( $action_names, array( 'jetpack_full_sync_comments' ) );
417    }
418
419    /**
420     * Expand the comment status change before the data is serialized and sent to the server.
421     *
422     * @access public
423     * @todo This is not used currently - let's implement it.
424     *
425     * @param array $args The hook parameters.
426     * @return array The expanded hook parameters.
427     */
428    public function expand_wp_comment_status_change( $args ) {
429        return array( $args[0], $this->filter_comment( $args[1] ) );
430    }
431
432    /**
433     * Expand the comment creation before the data is added to the Sync queue.
434     *
435     * @access public
436     *
437     * @param array $args The hook parameters.
438     * @return array The expanded hook parameters.
439     */
440    public function expand_wp_insert_comment( $args ) {
441        return array( $args[0], $this->filter_comment( $args[1] ) );
442    }
443
444    /**
445     * Filter a comment object to the fields we need.
446     *
447     * @access public
448     *
449     * @param \WP_Comment $comment The unfiltered comment object.
450     * @return \WP_Comment Filtered comment object.
451     */
452    public function filter_comment( $comment ) {
453        /**
454         * Filters whether to prevent sending comment data to .com
455         *
456         * Passing true to the filter will prevent the comment data from being sent
457         * to the WordPress.com.
458         * Instead we pass data that will still enable us to do a checksum against the
459         * Jetpacks data but will prevent us from displaying the data on in the API as well as
460         * other services.
461         *
462         * @since 1.6.3
463         * @since-jetpack 4.2.0
464         *
465         * @param boolean false prevent post data from bing synced to WordPress.com
466         * @param mixed $comment WP_COMMENT object
467         */
468        if ( apply_filters( 'jetpack_sync_prevent_sending_comment_data', false, $comment ) ) {
469            $blocked_comment                   = new \stdClass();
470            $blocked_comment->comment_ID       = $comment->comment_ID;
471            $blocked_comment->comment_date     = $comment->comment_date;
472            $blocked_comment->comment_date_gmt = $comment->comment_date_gmt;
473            $blocked_comment->comment_approved = 'jetpack_sync_blocked';
474            return $blocked_comment;
475        }
476
477        return $comment;
478    }
479
480    /**
481     * Whether a certain comment meta key is whitelisted for sync.
482     *
483     * @access public
484     *
485     * @param string $meta_key Comment meta key.
486     * @return boolean Whether the meta key is whitelisted.
487     */
488    public function is_whitelisted_comment_meta( $meta_key ) {
489        return in_array( $meta_key, Settings::get_setting( 'comment_meta_whitelist' ), true );
490    }
491
492    /**
493     * Handler for filtering out non-whitelisted comment meta.
494     *
495     * @access public
496     *
497     * @param array $args Hook args.
498     * @return array|boolean False if not whitelisted, the original hook args otherwise.
499     */
500    public function filter_meta( $args ) {
501        if ( ! is_array( $args ) || count( $args ) < 3 ) {
502            return false;
503        }
504        if ( $this->is_comment_type_allowed( $args[1] ) && $this->is_whitelisted_comment_meta( $args[2] ) ) {
505            return $args;
506        }
507
508        return false;
509    }
510
511    /**
512     * Expand the comment IDs to comment objects and meta before being serialized and sent to the server.
513     *
514     * @access public
515     *
516     * @param array $args The hook parameters.
517     * @return array The expanded hook parameters.
518     */
519    public function expand_comment_ids( $args ) {
520        list( $comment_ids, $previous_interval_end ) = $args;
521        $comments                                    = get_comments(
522            array(
523                'include_unapproved' => true,
524                'comment__in'        => $comment_ids,
525                'orderby'            => 'comment_ID',
526                'order'              => 'DESC',
527            )
528        );
529
530        return array(
531            $comments,
532            $this->get_metadata( $comment_ids, 'comment', Settings::get_setting( 'comment_meta_whitelist' ) ),
533            $previous_interval_end,
534        );
535    }
536
537    /**
538     * Expand the comment IDs to comment objects and meta before being serialized and sent to the server.
539     *
540     * @access public
541     *
542     * @param array $args The hook parameters.
543     * @return array The expanded hook parameters.
544     */
545    public function extract_comments_and_meta( $args ) {
546        list( $filtered_comments, $previous_end ) = $args;
547        return array(
548            $filtered_comments['objects'],
549            $filtered_comments['meta'],
550            $previous_end,
551        );
552    }
553
554    /**
555     * Given the Module Configuration and Status return the next chunk of items to send.
556     * This function also expands the posts and metadata and filters them based on the maximum size constraints.
557     *
558     * @param array $config This module Full Sync configuration.
559     * @param array $status This module Full Sync status.
560     * @param int   $chunk_size Chunk size.
561     *
562     * @return array
563     */
564    public function get_next_chunk( $config, $status, $chunk_size ) {
565
566        $comment_ids = parent::get_next_chunk( $config, $status, $chunk_size );
567        // If no comment IDs were fetched, return an empty array.
568        if ( empty( $comment_ids ) ) {
569            return array();
570        }
571        $comments = get_comments(
572            array(
573                'comment__in' => $comment_ids,
574                'orderby'     => 'comment_ID',
575                'order'       => 'DESC',
576            )
577        );
578        // If no comments were fetched, make sure to return the expected structure so that status is updated correctly.
579        if ( empty( $comments ) ) {
580            return array(
581                'object_ids' => $comment_ids,
582                'objects'    => array(),
583                'meta'       => array(),
584            );
585        }
586        // Get the comment IDs from the comments that were fetched.
587        $fetched_comment_ids = wp_list_pluck( $comments, 'comment_ID' );
588        $metadata            = $this->get_metadata( $fetched_comment_ids, 'comment', Settings::get_setting( 'comment_meta_whitelist' ) );
589
590        // Filter the comments and metadata based on the maximum size constraints.
591        list( $filtered_comment_ids, $filtered_comments, $filtered_comments_metadata ) = $this->filter_objects_and_metadata_by_size(
592            'comment',
593            $comments,
594            $metadata,
595            self::MAX_META_LENGTH, // Replace with appropriate comment meta length constant.
596            self::MAX_SIZE_FULL_SYNC
597        );
598
599        return array(
600            'object_ids' => $filtered_comment_ids,
601            'objects'    => $filtered_comments,
602            'meta'       => $filtered_comments_metadata,
603        );
604    }
605}