diff options
author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2006-12-07 16:58:13 +0000 |
---|---|---|
committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2006-12-07 16:58:13 +0000 |
commit | f9d5ef9fbb062b0c44c09207f947b515ab6dc66e (patch) | |
tree | d1cfa030e80a5f08ac79fb21281e647ee8a86026 /wp-includes/post.php | |
parent | d3ac809ed8a43bde6ea954329b3291fd9ca4aad5 (diff) | |
download | wordpress-mu-f9d5ef9fbb062b0c44c09207f947b515ab6dc66e.tar.gz wordpress-mu-f9d5ef9fbb062b0c44c09207f947b515ab6dc66e.tar.xz wordpress-mu-f9d5ef9fbb062b0c44c09207f947b515ab6dc66e.zip |
WP Merge to rev 4626
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@821 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-includes/post.php')
-rw-r--r-- | wp-includes/post.php | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/wp-includes/post.php b/wp-includes/post.php index 0e9110e..4d5dfd4 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -930,6 +930,7 @@ function &get_page(&$page, $output = OBJECT) { $_page = & $GLOBALS['page']; wp_cache_add($_page->ID, $_page, 'pages'); } else { + // shouldn't we just return NULL at this point? ~ Mark $_page = null; } } elseif ( is_object($page) ) { @@ -938,22 +939,29 @@ function &get_page(&$page, $output = OBJECT) { wp_cache_add($page->ID, $page, 'pages'); $_page = $page; } else { - if ( isset($GLOBALS['page']->ID) && ($page == $GLOBALS['page']->ID) ) { - $_page = & $GLOBALS['page']; - wp_cache_add($_page->ID, $_page, 'pages'); - } elseif ( !isset($_page) && $_page == $GLOBALS['post_cache'][$blog_id][$page] ) { - return get_post($page, $output); - } elseif ( isset($_page) && $_page == wp_cache_get($page, 'pages') ) { - // Got it. - } else { - $query = "SELECT * FROM $wpdb->posts WHERE ID= '$page' LIMIT 1"; - $_page = & $wpdb->get_row($query); - if ( 'post' == $_page->post_type ) - return get_post($_page, $output); - wp_cache_add($_page->ID, $_page, 'pages'); + // first, check the cache + if ( ! ( $_page = wp_cache_get($page, 'pages') ) ) { + // not in the page cache? + if ( isset($GLOBALS['page']->ID) && ($page == $GLOBALS['page']->ID) ) { // for is_page() views + // I don't think this code ever gets executed ~ Mark + $_page = & $GLOBALS['page']; + wp_cache_add($_page->ID, $_page, 'pages'); + } elseif ( isset($GLOBALS['post_cache'][$blog_id][$page]) ) { // it's actually a page, and is cached + return get_post($page, $output); + } else { // it's not in any caches, so off to the DB we go + // Why are we using assignment for this query? + $_page = & $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID= '$page' LIMIT 1"); + if ( 'post' == $_page->post_type ) + return get_post($_page, $output); + // Potential issue: we're not checking to see if the post_type = 'page' + // So all non-'post' posts will get cached as pages. + wp_cache_add($_page->ID, $_page, 'pages'); + } } } + // at this point, one way or another, $_post contains the page object + if ( $output == OBJECT ) { return $_page; } elseif ( $output == ARRAY_A ) { |