WordPress.org

Make WordPress Core

Changeset 15188


Ignore:
Timestamp:
06/10/2010 02:55:26 PM (9 years ago)
Author:
ryan
Message:

Fix global post stomping in get_post(). Turn get_page() into an alias of get_post(). Props westi. fixes #13753

File:
1 edited

Legend:

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

    r15169 r15188  
    370370    } else {
    371371        if ( is_object($post) )
    372             $post = $post->ID;
    373         $post = (int) $post;
    374         if ( ! $_post = wp_cache_get($post, 'posts') ) {
    375             $_post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d LIMIT 1", $post));
     372            $post_id = $post->ID;
     373        else
     374            $post_id = $post;
     375
     376        $post_id = (int) $post_id;
     377        if ( ! $_post = wp_cache_get($post_id, 'posts') ) {
     378            $_post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d LIMIT 1", $post_id));
    376379            if ( ! $_post )
    377380                return $null;
     
    28662869 */
    28672870function &get_page(&$page, $output = OBJECT, $filter = 'raw') {
    2868     if ( empty($page) ) {
    2869         if ( isset( $GLOBALS['post'] ) && isset( $GLOBALS['post']->ID ) ) {
    2870             return get_post($GLOBALS['post'], $output, $filter);
    2871         } else {
    2872             $page = null;
    2873             return $page;
    2874         }
    2875     }
    2876 
    2877     $the_page = get_post($page, $output, $filter);
    2878     return $the_page;
     2871    return get_post($page, $output, $filter);
    28792872}
    28802873
Note: See TracChangeset for help on using the changeset viewer.