Make WordPress Core

Opened 18 years ago

Closed 18 years ago

Last modified 18 years ago

#4251 closed defect (bug) (fixed)

Small error in get_posts not?

Reported by: momo360modena's profile momo360modena Owned by: rob1n's profile rob1n
Milestone: 2.3 Priority: normal
Severity: normal Version: 2.2
Component: General Keywords:
Focuses: Cc:

Description

line232:

   $query ="SELECT DISTINCT * FROM $wpdb->posts " ;

line240:

$query  = "SELECT DISTINCT * FROM $wpdb->posts ";

A doubloon no?

Attachments (1)

4251.diff (3.5 KB) - added by rob1n 18 years ago.

Download all attachments as: .zip

Change History (8)

#1 @momo360modena
18 years ago

doubloon => double entry..

#2 @rob1n
18 years ago

  • Milestone 2.2 deleted
  • Resolution set to invalid
  • Status changed from new to closed

No, it means that no two fields can be the same (distinct fields). Try it in phpMyAdmin. It works.

#3 @momo360modena
18 years ago

  • Resolution invalid deleted
  • Status changed from closed to reopened

Not a SQL problem... just double $query ...

	$query ="SELECT DISTINCT * FROM $wpdb->posts " ;
	$query .= ( empty( $category ) ? "" : ", $wpdb->post2cat " );
	$query .= ( empty( $meta_key ) ? "" : ", $wpdb->postmeta " );
	$query .= " WHERE (post_type = 'post' AND post_status = 'publish') $exclusions $inclusions ";
	$query .= ( empty( $category ) ? "" : "AND ($wpdb->posts.ID = $wpdb->post2cat.post_id AND $wpdb->post2cat.category_id = " . $category. ") " );
	$query .= ( empty( $meta_key ) | empty($meta_value)  ? "" : " AND ($wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb->postmeta.meta_key = '$meta_key' AND $wpdb->postmeta.meta_value = '$meta_value' )" );
	$query .= " GROUP BY $wpdb->posts.ID ORDER BY " . $orderby . " " . $order . " LIMIT " . $offset . ',' . $numberposts;

	$query  = "SELECT DISTINCT * FROM $wpdb->posts ";
	$query .= empty( $category ) ? '' : ", $wpdb->post2cat "; 
	$query .= empty( $meta_key ) ? '' : ", $wpdb->postmeta ";
	$query .= " WHERE 1=1 ";
	$query .= empty( $post_type ) ? '' : "AND post_type = '$post_type' ";
	$query .= empty( $post_status ) ? '' : "AND post_status = '$post_status' ";
	$query .= "$exclusions $inclusions " ;

#4 @rob1n
18 years ago

  • Milestone set to 2.4
  • Owner changed from anonymous to rob1n
  • Status changed from reopened to new

My misunderstanding. I'll look into this.

@rob1n
18 years ago

#5 @rob1n
18 years ago

  • Milestone changed from 2.4 to 2.3
  • Priority changed from high to normal
  • Severity changed from minor to normal
  • Status changed from new to assigned

Yep. Looks like a bad patch apply or maybe copy and paste. Confirmed affects 2.1, 2.2 and 2.3 (trunk). Patch attached. I'll commit this in a sec.

#6 @rob1n
18 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [5459]) Seeing double. Good spot momo360modena. fixes #4251 for 2.1, 2.2 and 2.3

#7 @momo360modena
18 years ago

Thanks ;)

Note: See TracTickets for help on using tickets.