| 939 | | if ( isset($GLOBALS['page']->ID) && ($page == $GLOBALS['page']->ID) ) { |
|---|
| 940 | | $_page = & $GLOBALS['page']; |
|---|
| 941 | | wp_cache_add($_page->ID, $_page, 'pages'); |
|---|
| 942 | | } elseif ( isset($GLOBALS['post_cache'][$blog_id][$page]) ) { |
|---|
| 943 | | return get_post($page, $output); |
|---|
| 944 | | } elseif ( $_page = wp_cache_get($page, 'pages') ) { |
|---|
| 945 | | // Got it. |
|---|
| 946 | | } else { |
|---|
| 947 | | $query = "SELECT * FROM $wpdb->posts WHERE ID= '$page' LIMIT 1"; |
|---|
| 948 | | $_page = & $wpdb->get_row($query); |
|---|
| 949 | | if ( 'post' == $_page->post_type ) |
|---|
| 950 | | return get_post($_page, $output); |
|---|
| 951 | | wp_cache_add($_page->ID, $_page, 'pages'); |
|---|
| 952 | | } |
|---|
| 953 | | } |
|---|
| | 940 | // first, check the cache |
|---|
| | 941 | if ( ! ( $_page = wp_cache_get($page, 'pages') ) ) { |
|---|
| | 942 | // not in the page cache? |
|---|
| | 943 | if ( isset($GLOBALS['page']->ID) && ($page == $GLOBALS['page']->ID) ) { // for is_page() views |
|---|
| | 944 | // I don't think this code ever gets executed ~ Mark |
|---|
| | 945 | $_page = & $GLOBALS['page']; |
|---|
| | 946 | wp_cache_add($_page->ID, $_page, 'pages'); |
|---|
| | 947 | } elseif ( isset($GLOBALS['post_cache'][$blog_id][$page]) ) { // it's actually a page, and is cached |
|---|
| | 948 | return get_post($page, $output); |
|---|
| | 949 | } else { // it's not in any caches, so off to the DB we go |
|---|
| | 950 | // Why are we using assignment for this query? |
|---|
| | 951 | $_page = & $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID= '$page' LIMIT 1"); |
|---|
| | 952 | if ( 'post' == $_page->post_type ) |
|---|
| | 953 | return get_post($_page, $output); |
|---|
| | 954 | // Potential issue: we're not checking to see if the post_type = 'page' |
|---|
| | 955 | // So all non-'post' posts will get cached as pages. |
|---|
| | 956 | wp_cache_add($_page->ID, $_page, 'pages'); |
|---|
| | 957 | } |
|---|
| | 958 | } |
|---|
| | 959 | } |
|---|
| | 960 | |
|---|
| | 961 | // at this point, one way or another, $_post contains the page object |
|---|