| 406 | $cache_value = array( |
| 407 | 'comment_ids' => $comment_ids, |
| 408 | 'found_comments' => $this->found_comments, |
| 409 | 'max_num_pages' => $this->max_num_pages, |
| 410 | ); |
| 411 | wp_cache_add( $cache_key, $cache_value, 'sites' ); |
| 412 | } else { |
| 413 | $comment_ids = $cache_value['comment_ids']; |
| 414 | $this->found_comments = $cache_value['found_comments']; |
| 415 | $this->max_num_pages = $cache_value['max_num_pages']; |
| 416 | } |
| 417 | |
415 | | if ( $comment_ids && $this->query_vars['number'] && ! $this->query_vars['no_found_rows'] ) { |
416 | | /** |
417 | | * Filters the query used to retrieve found comment count. |
418 | | * |
419 | | * @since 4.4.0 |
420 | | * |
421 | | * @param string $found_comments_query SQL query. Default 'SELECT FOUND_ROWS()'. |
422 | | * @param WP_Comment_Query $comment_query The `WP_Comment_Query` instance. |
423 | | */ |
424 | | $found_comments_query = apply_filters( 'found_comments_query', 'SELECT FOUND_ROWS()', $this ); |
425 | | $this->found_comments = (int) $wpdb->get_var( $found_comments_query ); |
426 | | |
427 | | $this->max_num_pages = ceil( $this->found_comments / $this->query_vars['number'] ); |
428 | | } |
429 | | |
| 904 | * Populates found_comments and max_num_pages properties for the current query |
| 905 | * if the limit clause was used. |
| 906 | * |
| 907 | * @since 4.6.0 |
| 908 | * @access private |
| 909 | * |
| 910 | * @global wpdb $wpdb WordPress database abstraction object. |
| 911 | */ |
| 912 | private function set_found_comments() { |
| 913 | global $wpdb; |
| 914 | |
| 915 | if ( $this->query_vars['number'] && ! $this->query_vars['no_found_rows'] ) { |
| 916 | /** |
| 917 | * Filters the query used to retrieve found comment count. |
| 918 | * |
| 919 | * @since 4.4.0 |
| 920 | * |
| 921 | * @param string $found_comments_query SQL query. Default 'SELECT FOUND_ROWS()'. |
| 922 | * @param WP_Comment_Query $comment_query The `WP_Comment_Query` instance. |
| 923 | */ |
| 924 | $found_comments_query = apply_filters( 'found_comments_query', 'SELECT FOUND_ROWS()', $this ); |
| 925 | |
| 926 | $this->found_comments = (int) $wpdb->get_var( $found_comments_query ); |
| 927 | $this->max_num_pages = ceil( $this->found_comments / $this->query_vars['number'] ); |
| 928 | } |
| 929 | } |
| 930 | |
| 931 | /** |