WordPress.org

Make WordPress Core


Ignore:
Timestamp:
03/04/2009 10:28:45 PM (12 years ago)
Author:
ryan
Message:

Fix calendar widget when there are no posts. Optimize query. Props Denis-de-Bernardy. fixes #6442

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/general-template.php

    r10660 r10708  
    931931        $cache = array();
    932932
    933     ob_start();
    934933    // Quick check. If we have no posts at all, abort!
    935934    if ( !$posts ) {
    936         $gotsome = $wpdb->get_var("SELECT ID from $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 1");
    937         if ( !$gotsome )
     935        $gotsome = $wpdb->get_var("SELECT 1 FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1");
     936        if ( !$gotsome ) {
     937            $cache[ $key ] = '';
     938            wp_cache_set( 'get_calendar', $cache, 'calendar' );
    938939            return;
    939     }
    940 
     940        }
     941    }
     942
     943    ob_start();
    941944    if ( isset($_GET['w']) )
    942945        $w = ''.intval($_GET['w']);
Note: See TracChangeset for help on using the changeset viewer.