Changeset 21628
- Timestamp:
- 08/27/2012 04:22:45 PM (12 years ago)
- Location:
- trunk/wp-includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/ms-functions.php
r21413 r21628 153 153 * @param int $blog_id ID of the blog. 154 154 * @param int $post_id ID of the post you're looking for. 155 * @return object The post.155 * @return WP_Post|null WP_Post on success or null on failure 156 156 */ 157 157 function get_blog_post( $blog_id, $post_id ) { 158 global $wpdb; 159 160 $key = $blog_id . '-' . $post_id; 161 $post = wp_cache_get( $key, 'global-posts' ); 162 if ( $post == false ) { 163 $post = $wpdb->get_row( $wpdb->prepare( 'SELECT * FROM ' . $wpdb->get_blog_prefix( $blog_id ) . 'posts WHERE ID = %d', $post_id ) ); 164 wp_cache_add( $key, $post, 'global-posts' ); 165 } 158 switch_to_blog( $blog_id ); 159 $post = get_post( $post_id ); 160 restore_current_blog(); 166 161 167 162 return $post; … … 314 309 * @since MU 1.0 315 310 * 316 * @param int $ _blog_id ID of the source blog.311 * @param int $blog_id ID of the source blog. 317 312 * @param int $post_id ID of the desired post. 318 313 * @return string The post's permalink 319 314 */ 320 function get_blog_permalink( $_blog_id, $post_id ) { 321 $key = "{$_blog_id}-{$post_id}-blog_permalink"; 322 $link = wp_cache_get( $key, 'site-options' ); 323 if ( $link == false ) { 324 switch_to_blog( $_blog_id ); 325 $link = get_permalink( $post_id ); 326 restore_current_blog(); 327 wp_cache_add( $key, $link, 'site-options', 360 ); 328 } 315 function get_blog_permalink( $blog_id, $post_id ) { 316 switch_to_blog( $blog_id ); 317 $link = get_permalink( $post_id ); 318 restore_current_blog(); 319 329 320 return $link; 330 321 } -
trunk/wp-includes/post.php
r21601 r21628 4518 4518 } 4519 4519 } 4520 4521 if ( is_multisite() )4522 wp_cache_delete( $wpdb->blogid . '-' . $post->ID, 'global-posts' );4523 4520 } 4524 4521
Note: See TracChangeset
for help on using the changeset viewer.