WordPress.org

Make WordPress Core

Changeset 14528


Ignore:
Timestamp:
05/10/10 00:58:39 (5 years ago)
Author:
ryan
Message:

Allow turning off object_term and postmeta cache updates. Turn off object_term updates in the wp_get_nav_menu_items() get_posts() query to avoid useless taxonomy query.

Location:
trunk/wp-includes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/nav-menu.php

    r14450 r14528  
    414414 
    415415    if ( ! empty( $items ) ) { 
    416         $defaults = array( 'order' => 'ASC', 'orderby' => 'menu_order', 'post_type' => 'nav_menu_item', 'post_status' => 'publish', 'output' => ARRAY_A, 'output_key' => 'menu_order', 'nopaging' => true ); 
     416        $defaults = array( 'order' => 'ASC', 'orderby' => 'menu_order', 'post_type' => 'nav_menu_item', 'post_status' => 'publish', 'output' => ARRAY_A, 'output_key' => 'menu_order', 'nopaging' => true, 
     417                          'update_post_term_cache' => false); 
    417418        $args = wp_parse_args( $args, $defaults ); 
    418419        if ( count( $items ) > 1 ) 
  • trunk/wp-includes/post.php

    r14521 r14528  
    40044004 * 
    40054005 * @param array $posts Array of Post objects 
    4006  * @param string $post_type The post type of the posts in $posts 
    4007  */ 
    4008 function update_post_caches(&$posts, $post_type = 'post') { 
     4006 * @param string $post_type The post type of the posts in $posts. Default is 'post'. 
     4007 * @param bool $update_term_cache Whether to update the term cache. Default is true. 
     4008 * @param bool $update_meta_cache Whether to update the meta cache. Default is true. 
     4009 */ 
     4010function update_post_caches(&$posts, $post_type = 'post', $update_term_cache = true, $update_meta_cache = true) { 
    40094011    // No point in doing all this work if we didn't match any posts. 
    40104012    if ( !$posts ) 
     
    40204022        $post_type = 'post'; 
    40214023 
    4022     if ( !is_array($post_type) && 'any' != $post_type ) 
     4024    if ( !is_array($post_type) && 'any' != $post_type && $update_term_cache ) 
    40234025        update_object_term_cache($post_ids, $post_type); 
    40244026 
    4025     update_postmeta_cache($post_ids); 
     4027    if ( $update_meta_cache ) 
     4028        update_postmeta_cache($post_ids); 
    40264029} 
    40274030 
  • trunk/wp-includes/query.php

    r14499 r14528  
    16221622            $q['cache_results'] = true; 
    16231623 
     1624        if ( !isset($q['update_post_term_cache']) ) 
     1625            $q['update_post_term_cache'] = true; 
     1626 
     1627        if ( !isset($q['update_post_meta_cache']) ) 
     1628            $q['update_post_meta_cache'] = true; 
     1629 
    16241630        if ( !isset($q['post_type']) ) { 
    16251631            if ( $this->is_search ) 
     
    25052511 
    25062512        if ( $q['cache_results'] ) 
    2507             update_post_caches($this->posts, $post_type); 
     2513            update_post_caches($this->posts, $post_type, $q['update_post_term_cache'], $q['update_post_meta_cache']); 
    25082514 
    25092515        if ( $this->post_count > 0 ) { 
Note: See TracChangeset for help on using the changeset viewer.