Make WordPress Core

Changeset 12376


Ignore:
Timestamp:
12/11/2009 11:29:19 PM (16 years ago)
Author:
markjaquith
Message:

Optimize Whoa Cowboy query. Only look back one hour. props mdawaffe. fixes #4366

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/comment.php

    r12321 r12376  
    551551    if ( current_user_can( 'manage_options' ) )
    552552        return; // don't throttle admins
    553     if ( $lasttime = $wpdb->get_var( $wpdb->prepare("SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_author_IP = %s OR comment_author_email = %s ORDER BY comment_date DESC LIMIT 1", $ip, $email) ) ) {
     553    $hour_ago = gmdate( 'Y-m-d H:i:s', time() - 3600 );
     554    if ( $lasttime = $wpdb->get_var( $wpdb->prepare( "SELECT `comment_date_gmt` FROM `$wpdb->comments` WHERE `comment_date_gmt` >= %s AND ( `comment_author_IP` = %s OR `comment_author_email` = %s ) ORDER BY `comment_date_gmt` DESC LIMIT 1", $hour_ago, $ip, $email ) ) ) {
    554555        $time_lastcomment = mysql2date('U', $lasttime, false);
    555556        $time_newcomment  = mysql2date('U', $date, false);
Note: See TracChangeset for help on using the changeset viewer.