Problems with the get_top_ranked_posts in the Popularity Contest plugin (1 post)

  1. lelandmcfarland
    Posted 5 years ago #

    I have been getting a MySQL error and I traced it back to the get_top_ranked_posts function in the Popularity Contest plugin.

    The function that is giving me troubles is:

    function get_top_ranked_posts($limit) {
    	global $wpdb;
    	$temp = $wpdb;
    	$join = apply_filters('posts_join', '');
    	$where = apply_filters('posts_where', '');
    	$groupby = apply_filters('posts_groupby', '');
    	if (!empty($groupby)) {
    		$groupby = ' GROUP BY '.$groupby;
    	else {
    		$groupby = ' GROUP BY '.$wpdb->posts.'.ID ';
    	$posts = $wpdb->get_results("
    		SELECT ID, post_title
    		FROM $wpdb->posts
    		LEFT JOIN $wpdb->ak_popularity pop
    		ON $wpdb->posts.ID = pop.post_id
    		WHERE post_status = 'publish'
    		AND post_date < NOW()
    		ORDER BY pop.total DESC
    		LIMIT ".intval($limit)
    	$wpdb = $temp;
    	return $posts;

    and from that I get the following SQL query:

    SELECT ID, post_title
    FROM wp_posts
    LEFT JOIN wp_ak_popularity pop
    ON wp_posts.ID = pop.post_id

    WHERE post_status = 'publish'
    AND post_date < NOW()
    AND ( ) AND (wp_posts.ID NOT IN ( 37733,854,27828,774,46877,52040,11,3,15670,1131 ))
    GROUP BY wp_posts.ID
    ORDER BY pop.total DESC
    LIMIT 10

    It looks like "$where = apply_filters('posts_where', '');" is returning "AND ( ) AND (wp_posts.ID NOT IN ( 37733,854,27828,774,46877,52040,11,3,15670,1131 ))" and it is then throwing a MySQL error.

    I am running version 2.0b2 of Popularity Contest.

    Any help would be very appreciated.

Topic Closed

This topic has been closed to new replies.

About this Topic

  • RSS feed for this topic
  • Started 5 years ago by lelandmcfarland
  • This topic is not resolved
  • WordPress version: 3.0.1