Changeset 23300
- Timestamp:
- 01/15/2013 05:32:35 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/post.php
r23265 r23300 3650 3650 return $pages; 3651 3651 3652 $cache = array();3652 // $args can be whatever, only use the args defined in defaults to compute the key 3653 3653 $key = md5( serialize( compact(array_keys($defaults)) ) ); 3654 if ( $cache = wp_cache_get( 'get_pages', 'posts' ) ) { 3655 if ( is_array($cache) && isset( $cache[ $key ] ) && is_array( $cache[ $key ] ) ) { 3656 // Convert to WP_Post instances 3657 $pages = array_map( 'get_post', $cache[ $key ] ); 3658 $pages = apply_filters( 'get_pages', $pages, $r ); 3659 return $pages; 3660 } 3654 $last_changed = wp_cache_get( 'last_changed', 'posts' ); 3655 if ( ! $last_changed ) 3656 $last_changed = wp_cache_set( 'last_changed', 1, 'posts' ); 3657 3658 $cache_key = "get_pages:$key:$last_changed"; 3659 if ( $cache = wp_cache_get( $cache_key, 'posts' ) ) { 3660 // Convert to WP_Post instances 3661 $pages = array_map( 'get_post', $cache ); 3662 $pages = apply_filters('get_pages', $pages, $r); 3663 return $pages; 3661 3664 } 3662 3665 … … 3828 3831 } 3829 3832 3830 $cache[ $key ] = $pages; 3831 wp_cache_set( 'get_pages', $cache, 'posts' ); 3833 $page_structure = array(); 3834 foreach ( $pages as $page ) 3835 $page_structure[] = $page->ID; 3836 3837 wp_cache_set( $cache_key, $page_structure, 'posts' ); 3832 3838 3833 3839 // Convert to WP_Post instances … … 4664 4670 do_action( 'clean_page_cache', $post->ID ); 4665 4671 } 4672 4673 if ( function_exists( 'wp_cache_incr' ) ) { 4674 wp_cache_incr( 'last_changed', 1, 'posts' ); 4675 } else { 4676 $last_changed = wp_cache_get( 'last_changed', 'posts' ); 4677 wp_cache_set( 'last_changed', $last_changed + 1, 'posts' ); 4678 } 4666 4679 } 4667 4680
Note: See TracChangeset
for help on using the changeset viewer.