Ticket #24826: comment.php.diff
File comment.php.diff, 3.1 KB (added by , 12 years ago) |
---|
-
wp-includes/comment.php
200 200 var $meta_query = false; 201 201 202 202 /** 203 * Execute the query203 * Query vars set by the user 204 204 * 205 205 * @since 3.1.0 206 * @access public 207 * @var array 208 */ 209 var $query_vars; 210 211 /** 212 * List of comments. 206 213 * 207 * @param string|array $query_vars 208 * @return int|array 214 * @since 3.7 215 * @access public 216 * @var array 209 217 */ 210 function query( $query_vars ) { 211 global $wpdb; 218 var $comments; 212 219 220 /** 221 * Constructor. 222 * 223 * Sets up the comment query, if parameter is not empty. 224 * 225 * @since 3.7 226 * @access public 227 * 228 * @param string $query URL query string. 229 * @return WP_Comment_Query 230 */ 231 function __construct($query = '') { 232 if ( ! empty($query) ) { 233 $this->query($query); 234 } 235 } 236 237 /** 238 * Parse a query string and set query type booleans. 239 * 240 * @since 1.5.0 241 * @access public 242 * 243 * @param string|array $query Optional query. 244 */ 245 function parse_query( $query = '' ) { 246 if ( empty( $query ) ) { 247 $query = $this->query_vars; 248 } 213 249 $defaults = array( 214 250 'author_email' => '', 215 251 'ID' => '', … … 236 272 'meta_query' => '', 237 273 ); 238 274 275 $this->query_vars = wp_parse_args( $query, $defaults ); 276 do_action_ref_array('parse_comment_query', array(&$this)); 277 } 278 279 /** 280 * Sets up the WordPress query by parsing query string. 281 * 282 * @since 1.5.0 283 * @access public 284 * 285 * @param string $query_vars URL query string. 286 * @return array List of posts. 287 */ 288 function query( $query_vars ) { 289 $this->query_vars = wp_parse_args( $query_vars ); 290 return $this->get_comments(); 291 } 292 293 /** 294 * Execute the query 295 * 296 * @since 3.7 297 * 298 * @return int|array 299 */ 300 function get_comments() { 301 global $wpdb; 302 239 303 $groupby = ''; 240 304 241 $this-> query_vars = wp_parse_args( $query_vars, $defaults);305 $this->parse_query(); 242 306 243 307 // Parse meta query 244 308 $this->meta_query = new WP_Meta_Query(); … … 247 311 do_action_ref_array( 'pre_get_comments', array( &$this ) ); 248 312 extract( $this->query_vars, EXTR_SKIP ); 249 313 250 // $args can be whatever, only use the args defined in defaults to compute the key251 $key = md5( serialize( compact(array_keys($ defaults)) ) );314 // $args can be whatever, only use the args defined in the query_vars to compute the key 315 $key = md5( serialize( compact(array_keys($this->query_vars)) ) ); 252 316 $last_changed = wp_cache_get( 'last_changed', 'comment' ); 253 317 if ( ! $last_changed ) { 254 318 $last_changed = microtime(); … … 256 320 } 257 321 $cache_key = "get_comments:$key:$last_changed"; 258 322 259 if ( $cache = wp_cache_get( $cache_key, 'comment' ) ) 323 if ( $cache = wp_cache_get( $cache_key, 'comment' ) ) { 324 $this->comments = $cache; 260 325 return $cache; 326 } 261 327 262 328 $post_id = absint($post_id); 263 329 … … 380 446 $comments = apply_filters_ref_array( 'the_comments', array( $comments, &$this ) ); 381 447 382 448 wp_cache_add( $cache_key, $comments, 'comment' ); 449 $this->comments = $comments; 383 450 384 451 return $comments; 385 452 }