Ticket #21120: 21120.3.patch
File 21120.3.patch, 2.9 KB (added by , 13 years ago) |
---|
-
wp-admin/includes/class-wp-posts-list-table.php
81 81 function prepare_items() { 82 82 global $post_type_object, $avail_post_stati, $wp_query, $per_page, $mode; 83 83 84 add_action( 'pre_get_posts', array( $this, 'enable_author_cache' ) ); 84 85 $avail_post_stati = wp_edit_posts_query(); 86 remove_action( 'pre_get_posts' , array( $this, 'enable_author_cache' ) ); 85 87 86 88 $this->hierarchical_display = ( $post_type_object->hierarchical && 'menu_order title' == $wp_query->query['orderby'] ); 87 89 … … 1055 1057 </tbody></table></form> 1056 1058 <?php 1057 1059 } 1060 1061 /** 1062 * Enable author caching 1063 * @param WP_Query $query 1064 */ 1065 function enable_author_cache( $query ) { 1066 $query->set( 'update_author_cache', true ); 1067 } 1058 1068 } -
wp-includes/post.php
5351 5351 update_post_caches( $fresh_posts, 'any', $update_term_cache, $update_meta_cache ); 5352 5352 } 5353 5353 } 5354 5355 /** 5356 * Prime the user cache 5357 * 5358 * @since 3.5.0 5359 * 5360 * @access private 5361 * 5362 * @param array $user_ids 5363 */ 5364 function _prime_user_cache( $user_ids ) { 5365 foreach ( $user_ids as $user_id ) { 5366 5367 // Skip if the user is cached already 5368 $user = wp_cache_get( $user_id, 'users' ); 5369 if ( !empty( $user ) && !empty( $user->caps ) ) 5370 continue; 5371 5372 // Get and cache the user 5373 $userdata = WP_User::get_data_by( 'id', $user_id ); 5374 $user = new WP_User; 5375 $user->init( $userdata ); 5376 update_user_caches( $user ); 5377 wp_cache_set( $userdata->ID, $user, 'users' ); 5378 } 5379 } -
wp-includes/pluggable.php
138 138 if ( !$userdata ) 139 139 return false; 140 140 141 $user = wp_cache_get( $userdata->ID, 'users' ); 142 143 if ( !empty( $user ) && !empty( $user->caps ) ) 144 return $user; 145 141 146 $user = new WP_User; 142 147 $user->init( $userdata ); 143 148 149 wp_cache_set( $userdata->ID, $user, 'users' ); 144 150 return $user; 145 151 } 146 152 endif; -
wp-includes/query.php
2651 2651 $this->found_posts = $this->max_num_pages = 0; 2652 2652 $this->posts = array(); 2653 2653 } 2654 2655 if ( isset( $this->query_vars['update_author_cache'] ) && ( $this->query_vars['update_author_cache'] ) ) { 2656 $authors = array_unique( wp_list_pluck( $this->posts, 'post_author' ) ); 2657 _prime_user_cache( $authors ); 2658 } 2659 2654 2660 } else { 2655 2661 $this->posts = $wpdb->get_results( $this->request ); 2656 2662 $this->set_found_posts( $q, $limits );