Make WordPress Core

Ticket #15805: 15805.1.patch

File 15805.1.patch, 1.0 KB (added by tollmanz, 12 years ago)
  • src/wp-includes/post.php

     
    34843484 * @param string $post_type Optional. Post type. Default page.
    34853485 * @return WP_Post|null WP_Post on success or null on failure
    34863486 */
    3487 function get_page_by_title($page_title, $output = OBJECT, $post_type = 'page' ) {
     3487function get_page_by_title( $page_title, $output = OBJECT, $post_type = 'page' ) {
    34883488        global $wpdb;
    3489         $page = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type= %s", $page_title, $post_type ) );
     3489
     3490        $cache_id = 'page_title_' . $page_title . $post_type;
     3491
     3492        if ( false === $page = wp_cache_get( $cache_id, 'posts' ) ) {
     3493                $page = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type= %s", $page_title, $post_type ) );
     3494                wp_cache_add( $cache_id, $page, 'posts' );
     3495        }
     3496
    34903497        if ( $page )
    34913498                return get_post( $page, $output );
    34923499