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,50 +264,50 @@ function the_meta() {
function get_pages($args = '') {
global $wpdb, $cache_pages;
if (!isset($cache_pages) || empty($cache_pages)) {
parse_str($args, $r);
parse_str($args, $r);
if (!isset($r['child_of'])) $r['child_of'] = 0;
if (!isset($r['sort_column'])) $r['sort_column'] = 'post_title';
if (!isset($r['sort_order'])) $r['sort_order'] = 'ASC';
if (!isset($r['child_of'])) $r['child_of'] = 0;
if (!isset($r['sort_column'])) $r['sort_column'] = 'post_title';
if (!isset($r['sort_order'])) $r['sort_order'] = 'ASC';
$exclusions = '';
if (!empty($r['exclude'])) {
$expages = preg_split('/[\s,]+/',$r['exclude']);
if (count($expages)) {
foreach ($expages as $expage) {
$exclusions .= ' AND ID <> ' . intval($expage) . ' ';
}
}
}
$dates = ",UNIX_TIMESTAMP(post_modified) AS time_modified";
$dates .= ",UNIX_TIMESTAMP(post_date) AS time_created";
$post_parent = '';
if ($r['child_of']) {
$post_parent = ' AND post_parent=' . $r['child_of'] . ' ';
}
$pages = $wpdb->get_results("SELECT " .
"ID, post_title, post_name, post_parent " .
"$dates " .
"FROM $wpdb->posts " .
"WHERE post_status = 'static' " .
"$post_parent" .
"$exclusions " .
"ORDER BY " . $r['sort_column'] . " " . $r['sort_order']);
$cache_pages = array();
if (count($pages)) {
foreach($pages as $page) {
$cache_pages[$page->ID] = $page;
$exclusions = '';
if (!empty($r['exclude'])) {
$expages = preg_split('/[\s,]+/',$r['exclude']);
if (count($expages)) {
foreach ($expages as $expage) {
$exclusions .= ' AND ID <> ' . intval($expage) . ' ';
}
}
}
return $cache_pages;
$dates = ",UNIX_TIMESTAMP(post_modified) AS time_modified";
$dates .= ",UNIX_TIMESTAMP(post_date) AS time_created";
$post_parent = '';
if ($r['child_of']) {
$post_parent = ' AND post_parent=' . $r['child_of'] . ' ';
}
$pages = $wpdb->get_results("SELECT " .
"ID, post_title, post_name, post_parent " .
"$dates " .
"FROM $wpdb->posts " .
"WHERE post_status = 'static' " .
"$post_parent" .
"$exclusions " .
"ORDER BY " . $r['sort_column'] . " " . $r['sort_order']);
// Update page cache.
if (count($pages)) {
foreach($pages as $page) {
$cache_pages[$page->ID] = $page;
}
}
if ( empty($pages) )
$pages = array();
return $pages;
}
function wp_list_pages($args = '') {