Page caching fixes. Mosquito bugs 920, 927, and 934.

git-svn-id: https://develop.svn.wordpress.org/trunk@2421 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2005-03-09 03:16:30 +00:00
parent d2b598c1c3
commit 3bacf431ae
2 changed files with 48 additions and 40 deletions

View File

@ -997,8 +997,11 @@ function remove_action($tag, $function_to_remove, $priority = 10, $accepted_args
function get_page_uri($page_id) {
global $wpdb, $cache_pages;
$dates = ",UNIX_TIMESTAMP(post_modified) AS time_modified";
$dates .= ",UNIX_TIMESTAMP(post_date) AS time_created";
if (!isset($cache_pages[$page_id])) {
$cache_pages[$page_id] = $wpdb->get_row("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE ID = '$page_id'");
$cache_pages[$page_id] = $wpdb->get_row("SELECT ID, post_title, post_name, post_parent $dates FROM $wpdb->posts WHERE ID = '$page_id'");
}
$page = $cache_pages[$page_id];
@ -1010,7 +1013,12 @@ function get_page_uri($page_id) {
}
while ($page->post_parent != 0) {
$page = $wpdb->get_row("SELECT post_name, post_parent FROM $wpdb->posts WHERE ID = '$page->post_parent'");
if (isset($cache_pages[$page->post_parent])) {
$page = $cache_pages[$page->post_parent];
} else {
$page = $wpdb->get_row("SELECT ID, post_title, post_name, post_parent $dates FROM $wpdb->posts WHERE ID = '$page->post_parent'");
$cache_pages[$page->ID] = $page;
}
$uri = urldecode($page->post_name) . "/" . $uri;
}

View File

@ -264,8 +264,6 @@ function the_meta() {
function get_pages($args = '') {
global $wpdb, $cache_pages;
if (!isset($cache_pages) || empty($cache_pages)) {
parse_str($args, $r);
if (!isset($r['child_of'])) $r['child_of'] = 0;
@ -299,15 +297,17 @@ function get_pages($args = '') {
"$exclusions " .
"ORDER BY " . $r['sort_column'] . " " . $r['sort_order']);
$cache_pages = array();
// Update page cache.
if (count($pages)) {
foreach($pages as $page) {
$cache_pages[$page->ID] = $page;
}
}
}
return $cache_pages;
if ( empty($pages) )
$pages = array();
return $pages;
}
function wp_list_pages($args = '') {