mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
Eliminate comment_date_gmt <= now from get_lastcommentmodified() queries. fixes #5650
git-svn-id: http://svn.automattic.com/wordpress/trunk@6610 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
8c55d60d5b
commit
74cad1dac8
@ -199,24 +199,26 @@ function get_commentdata( $comment_ID, $no_cache = 0, $include_unapproved = fals
|
||||
*/
|
||||
function get_lastcommentmodified($timezone = 'server') {
|
||||
global $cache_lastcommentmodified, $wpdb;
|
||||
|
||||
if ( isset($cache_lastcommentmodified[$timezone]) )
|
||||
return $cache_lastcommentmodified[$timezone];
|
||||
|
||||
$add_seconds_server = date('Z');
|
||||
$now = current_time('mysql', 1);
|
||||
if ( !isset($cache_lastcommentmodified[$timezone]) ) {
|
||||
switch ( strtolower($timezone)) {
|
||||
case 'gmt':
|
||||
$lastcommentmodified = $wpdb->get_var($wpdb->prepare("SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_date_gmt <= %s AND comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1", $now));
|
||||
break;
|
||||
case 'blog':
|
||||
$lastcommentmodified = $wpdb->get_var($wpdb->prepare("SELECT comment_date FROM $wpdb->comments WHERE comment_date_gmt <= %s AND comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1", $now));
|
||||
break;
|
||||
case 'server':
|
||||
$lastcommentmodified = $wpdb->get_var($wpdb->prepare("SELECT DATE_ADD(comment_date_gmt, INTERVAL %s SECOND) FROM $wpdb->comments WHERE comment_date_gmt <= %s AND comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1", $add_seconds_server, $now));
|
||||
break;
|
||||
}
|
||||
$cache_lastcommentmodified[$timezone] = $lastcommentmodified;
|
||||
} else {
|
||||
$lastcommentmodified = $cache_lastcommentmodified[$timezone];
|
||||
|
||||
switch ( strtolower($timezone)) {
|
||||
case 'gmt':
|
||||
$lastcommentmodified = $wpdb->get_var("SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1");
|
||||
break;
|
||||
case 'blog':
|
||||
$lastcommentmodified = $wpdb->get_var("SELECT comment_date FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1");
|
||||
break;
|
||||
case 'server':
|
||||
$lastcommentmodified = $wpdb->get_var($wpdb->prepare("SELECT DATE_ADD(comment_date_gmt, INTERVAL %s SECOND) FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1", $add_seconds_server));
|
||||
break;
|
||||
}
|
||||
|
||||
$cache_lastcommentmodified[$timezone] = $lastcommentmodified;
|
||||
|
||||
return $lastcommentmodified;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user