WordPress.org

Make WordPress Core

Changeset 16206


Ignore:
Timestamp:
11/05/10 15:26:15 (6 years ago)
Author:
ryan
Message:

Eliminate some queries in get_page_by_path() by consulting cache. Props Denis-de-Bernardy, wojtek.szkutnik. fixes #11373

File:
1 edited

Legend:

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

    r16202 r16206  
    31183118        $curpage = $page; 
    31193119        while ( $curpage->post_parent != 0 ) { 
    3120             $curpage = $wpdb->get_row( $wpdb->prepare( "SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE ID = %d and post_type = %s", $curpage->post_parent, $post_type )); 
     3120            $post_parent = $curpage->post_parent;  
     3121            $curpage = wp_cache_get( $post_parent, 'posts' );  
     3122            if ( false === $curpage )  
     3123                $curpage = $wpdb->get_row( $wpdb->prepare( "SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE ID = %d and post_type = %s", $post_parent, $post_type ) ); 
    31213124            $path = '/' . $curpage->post_name . $path; 
    31223125        } 
Note: See TracChangeset for help on using the changeset viewer.