mirror of
git://develop.git.wordpress.org/
synced 2025-01-18 21:28:02 +01:00
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:
parent
d2b598c1c3
commit
3bacf431ae
@ -997,8 +997,11 @@ function remove_action($tag, $function_to_remove, $priority = 10, $accepted_args
|
|||||||
function get_page_uri($page_id) {
|
function get_page_uri($page_id) {
|
||||||
global $wpdb, $cache_pages;
|
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])) {
|
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];
|
$page = $cache_pages[$page_id];
|
||||||
@ -1010,7 +1013,12 @@ function get_page_uri($page_id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
while ($page->post_parent != 0) {
|
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;
|
$uri = urldecode($page->post_name) . "/" . $uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,50 +264,50 @@ function the_meta() {
|
|||||||
function get_pages($args = '') {
|
function get_pages($args = '') {
|
||||||
global $wpdb, $cache_pages;
|
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;
|
$exclusions = '';
|
||||||
if (!isset($r['sort_column'])) $r['sort_column'] = 'post_title';
|
if (!empty($r['exclude'])) {
|
||||||
if (!isset($r['sort_order'])) $r['sort_order'] = 'ASC';
|
$expages = preg_split('/[\s,]+/',$r['exclude']);
|
||||||
|
if (count($expages)) {
|
||||||
$exclusions = '';
|
foreach ($expages as $expage) {
|
||||||
if (!empty($r['exclude'])) {
|
$exclusions .= ' AND ID <> ' . intval($expage) . ' ';
|
||||||
$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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 = '') {
|
function wp_list_pages($args = '') {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user