382 | | /* |
383 | | * Only use the args defined in the query_var_defaults to compute the key, |
384 | | * but ignore 'fields', which does not affect query results. |
385 | | */ |
386 | | $_args = wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) ); |
387 | | unset( $_args['fields'] ); |
| 382 | $comment_ids = null; |
| 383 | |
| 384 | /** |
| 385 | * Filter the comments array before the query takes place. |
| 386 | * |
| 387 | * Return a non-null value to bypass WordPress's default comment queries. |
| 388 | * |
| 389 | * |
| 390 | * @since 5.3.0 |
| 391 | * |
| 392 | * @param array|null $comment_ids Return an array of comment data to short-circuit WP's comment query, |
| 393 | * or null to allow WP to run its normal queries. |
| 394 | * @param WP_Comment_Query $this The WP_Comment_Query instance, passed by reference. |
| 395 | */ |
| 396 | $comment_ids = apply_filters_ref_array( 'comments_pre_query', array( $comment_ids, &$this ) ); |
| 397 | |
| 398 | if ( null === $comment_ids ) { |
| 399 | /* |
| 400 | * Only use the args defined in the query_var_defaults to compute the key, |
| 401 | * but ignore 'fields', which does not affect query results. |
| 402 | */ |
| 403 | $_args = wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) ); |
| 404 | unset( $_args['fields'] ); |
392 | | $cache_key = "get_comments:$key:$last_changed"; |
393 | | $cache_value = wp_cache_get( $cache_key, 'comment' ); |
394 | | if ( false === $cache_value ) { |
395 | | $comment_ids = $this->get_comment_ids(); |
396 | | if ( $comment_ids ) { |
397 | | $this->set_found_comments(); |
398 | | } |
| 409 | $cache_key = "get_comments:$key:$last_changed"; |
| 410 | $cache_value = wp_cache_get( $cache_key, 'comment' ); |
| 411 | if ( false === $cache_value ) { |
| 412 | $comment_ids = $this->get_comment_ids(); |
| 413 | if ( $comment_ids ) { |
| 414 | $this->set_found_comments(); |
| 415 | } |
400 | | $cache_value = array( |
401 | | 'comment_ids' => $comment_ids, |
402 | | 'found_comments' => $this->found_comments, |
403 | | ); |
404 | | wp_cache_add( $cache_key, $cache_value, 'comment' ); |
405 | | } else { |
406 | | $comment_ids = $cache_value['comment_ids']; |
407 | | $this->found_comments = $cache_value['found_comments']; |
| 417 | $cache_value = array( |
| 418 | 'comment_ids' => $comment_ids, |
| 419 | 'found_comments' => $this->found_comments, |
| 420 | ); |
| 421 | wp_cache_add( $cache_key, $cache_value, 'comment' ); |
| 422 | } else { |
| 423 | $comment_ids = $cache_value['comment_ids']; |
| 424 | $this->found_comments = $cache_value['found_comments']; |
| 425 | } |