mirror of
git://develop.git.wordpress.org/
synced 2025-01-18 05:18:42 +01:00
Eliminate comment_date_gmt <= now from get_lastcommentmodified() queries. fixes #5650
git-svn-id: https://develop.svn.wordpress.org/trunk@6610 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
c606c5bc63
commit
830b718dcd
@ -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…
x
Reference in New Issue
Block a user