Changeset 4521

Show
Ignore:
Timestamp:
11/23/06 17:21:08 (2 years ago)
Author:
matt
Message:

Caching for get_pages

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-includes/post.php

    r4518 r4521  
    10391039    extract($r); 
    10401040 
     1041    $key = md5( serialize( $r ) ); 
     1042    if ( $cache = wp_cache_get( 'get_pages', 'page' ) ) 
     1043        if ( isset( $cache[ $key ] ) ) 
     1044            return apply_filters('get_pages', $cache[ $key ], $r ); 
     1045 
    10411046    $inclusions = ''; 
    10421047    if ( !empty($include) ) { 
    1043         $child_of = 0; //ignore child_of, exclude, meta_key, and meta_value params if using include 
    1044         $exclude = ''; 
     1048        $child_of = 0; //ignore child_of, exclude, meta_key, and meta_value params if using include  
     1049        $exclude = '';   
    10451050        $meta_key = ''; 
    10461051        $meta_value = ''; 
     
    10551060        } 
    10561061    } 
    1057     if (!empty($inclusions)) 
    1058         $inclusions .= ')'; 
     1062    if (!empty($inclusions))  
     1063        $inclusions .= ')';     
    10591064 
    10601065    $exclusions = ''; 
     
    11181123        $pages = & get_page_children($child_of, $pages); 
    11191124 
     1125    $cache[ $key ] = $pages; 
     1126    wp_cache_set( 'get_pages', $cache, 'page' ); 
     1127 
    11201128    return $pages; 
    11211129} 
     1130 
     1131function delete_get_pages_cache() { 
     1132    wp_cache_delete( 'get_pages', 'page' ); 
     1133} 
     1134add_action( 'save_post', 'delete_get_pages_cache' ); 
    11221135 
    11231136function generate_page_uri_index() {