From 430a8cb2cfa02ca022d4e0bc7a3dbf86bf5d34da Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 28 Apr 2009 05:42:30 +0000 Subject: [PATCH] Limit get_lastpost* functions to post_type=post. Props Denis-de-Bernardy. fixes #9636 git-svn-id: http://svn.automattic.com/wordpress/trunk@11108 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-app.php | 2 +- wp-includes/post.php | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/wp-app.php b/wp-app.php index 29994e43e1..20ea9a29c1 100644 --- a/wp-app.php +++ b/wp-app.php @@ -1118,7 +1118,7 @@ EOD; -Copyright +Copyright get_var("SELECT post_date_gmt FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1"); + $lastpostdate = $wpdb->get_var("SELECT post_date_gmt FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY post_date_gmt DESC LIMIT 1"); break; case 'blog': - $lastpostdate = $wpdb->get_var("SELECT post_date FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1"); + $lastpostdate = $wpdb->get_var("SELECT post_date FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY post_date_gmt DESC LIMIT 1"); break; case 'server': - $lastpostdate = $wpdb->get_var("SELECT DATE_ADD(post_date_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1"); + $lastpostdate = $wpdb->get_var("SELECT DATE_ADD(post_date_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY post_date_gmt DESC LIMIT 1"); break; } $cache_lastpostdate[$blog_id][$timezone] = $lastpostdate; @@ -2970,13 +2970,13 @@ function get_lastpostmodified($timezone = 'server') { if ( !isset($cache_lastpostmodified[$blog_id][$timezone]) ) { switch(strtolower($timezone)) { case 'gmt': - $lastpostmodified = $wpdb->get_var("SELECT post_modified_gmt FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1"); + $lastpostmodified = $wpdb->get_var("SELECT post_modified_gmt FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY post_modified_gmt DESC LIMIT 1"); break; case 'blog': - $lastpostmodified = $wpdb->get_var("SELECT post_modified FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1"); + $lastpostmodified = $wpdb->get_var("SELECT post_modified FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY post_modified_gmt DESC LIMIT 1"); break; case 'server': - $lastpostmodified = $wpdb->get_var("SELECT DATE_ADD(post_modified_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1"); + $lastpostmodified = $wpdb->get_var("SELECT DATE_ADD(post_modified_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY post_modified_gmt DESC LIMIT 1"); break; } $lastpostdate = get_lastpostdate($timezone);