Changeset 34544 for trunk/src/wp-includes/class-wp-comment-query.php
- Timestamp:
- 09/25/2015 02:34:20 PM (11 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/class-wp-comment-query.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-comment-query.php
r34542 r34544 97 97 98 98 /** 99 * The amount of found comments for the current query. 100 * 101 * @since 4.4.0 102 * @access public 103 * @var int 104 */ 105 public $found_comments = 0; 106 107 /** 108 * The number of pages. 109 * 110 * @since 4.4.0 111 * @access public 112 * @var int 113 */ 114 public $max_num_pages = 0; 115 116 /** 99 117 * Make private/protected methods readable for backwards compatibility. 100 118 * … … 120 138 * @since 4.2.0 121 139 * @since 4.4.0 `$parent__in` and `$parent__not_in` were added. 122 * @since 4.4.0 Order by `comment__in` was added. `$update_comment_meta_cache` wasadded.140 * @since 4.4.0 Order by `comment__in` was added. `$update_comment_meta_cache` and `$no_found_rows` were added. 123 141 * @access public 124 142 * … … 149 167 * @type int $offset Number of comments to offset the query. Used to build LIMIT clause. 150 168 * Default 0. 169 * @type bool $no_found_rows Whether to disable the `SQL_CALC_FOUND_ROWS` query. 170 * Default: true. 151 171 * @type string|array $orderby Comment status or array of statuses. To use 'meta_value' or 152 172 * 'meta_value_num', `$meta_key` must also be defined. To sort by … … 204 224 'number' => '', 205 225 'offset' => '', 226 'no_found_rows' => true, 206 227 'orderby' => '', 207 228 'order' => 'DESC', … … 331 352 $comment_ids = array_map( 'intval', $comment_ids ); 332 353 354 $this->comment_count = count( $this->comments ); 355 356 if ( $comment_ids && $this->query_vars['number'] && ! $this->query_vars['no_found_rows'] ) { 357 /** 358 * Filter the query used to retrieve found comment count. 359 * 360 * @since 4.4.0 361 * 362 * @param string $found_comments_query SQL query. Default 'SELECT FOUND_ROWS()'. 363 * @param WP_Comment_Query $comment_query The `WP_Comment_Query` instance. 364 */ 365 $found_comments_query = apply_filters( 'found_comments_query', 'SELECT FOUND_ROWS()', $this ); 366 $this->found_comments = (int) $wpdb->get_var( $found_comments_query ); 367 368 $this->max_num_pages = ceil( $this->found_comments / $this->query_vars['number'] ); 369 } 370 333 371 if ( 'ids' == $this->query_vars['fields'] ) { 334 372 $this->comments = $comment_ids; … … 739 777 } 740 778 741 $this->sql_clauses['select'] = "SELECT $fields"; 779 $found_rows = ''; 780 if ( ! $this->query_vars['no_found_rows'] ) { 781 $found_rows = 'SQL_CALC_FOUND_ROWS'; 782 } 783 784 $this->sql_clauses['select'] = "SELECT $found_rows $fields"; 742 785 $this->sql_clauses['from'] = "FROM $wpdb->comments $join"; 743 786 $this->sql_clauses['groupby'] = $groupby;
Note: See TracChangeset
for help on using the changeset viewer.