Ticket #2967: 2967.patch
File 2967.patch, 1.9 KB (added by , 8 years ago) |
---|
-
trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-support/functions.php
248 248 return 0; 249 249 } 250 250 251 $count = (int) $wpdb->get_var( $wpdb->prepare( 252 "SELECT COUNT(*) 251 // Check cache. 252 $count = wp_cache_get( 'user_topics_count_'.$user_id, 'user-topics-count' ); 253 if ( false === $count ) { 254 $count = (int) $wpdb->get_var( $wpdb->prepare( 255 "SELECT COUNT(*) 253 256 FROM {$wpdb->posts} 254 257 WHERE post_type = 'topic' 255 258 AND post_status IN ( 'publish', 'closed' ) 256 259 AND post_parent <> %d 257 260 AND post_author = %d", 258 WordPressdotorg\Forums\Plugin::REVIEWS_FORUM_ID, 259 $user_id 260 ) ); 261 WordPressdotorg\Forums\Plugin::REVIEWS_FORUM_ID, 262 $user_id 263 ) ); 264 wp_cache_add( 'user_topics_count_'.$user_id, $count, 'user-topics-count' ); 265 } 261 266 262 267 return $count; 263 268 } … … 282 287 return 0; 283 288 } 284 289 285 $count = (int) $wpdb->get_var( $wpdb->prepare( 286 "SELECT COUNT(*) 290 // Check cache. 291 $count = wp_cache_get( 'user_reviews_count_'.$user_id, 'user-reviews-count' ); 292 if ( false === $count ) { 293 $count = (int) $wpdb->get_var( $wpdb->prepare( 294 "SELECT COUNT(*) 287 295 FROM {$wpdb->posts} 288 296 WHERE post_type = 'topic' 289 297 AND post_status IN ( 'publish', 'closed' ) 290 298 AND post_parent = %d 291 299 AND post_author = %d", 292 WordPressdotorg\Forums\Plugin::REVIEWS_FORUM_ID, 293 $user_id 294 ) ); 300 WordPressdotorg\Forums\Plugin::REVIEWS_FORUM_ID, 301 $user_id 302 ) ); 303 wp_cache_add( 'user_reviews_count_'.$user_id, $count, 'user-reviews-count' ); 304 } 295 305 296 306 return $count; 297 307 } … … 530 540 531 541 return $user_can_stick; 532 542 } 533 543 534 544 /** 535 545 * Correct reply URLs for pending posts. 536 546 *