Ticket #4251 (closed defect: fixed)

Opened 1 year ago

Last modified 1 year ago

Small error in get_posts not?

Reported by: momo360modena Assigned to: rob1n
Priority: normal Milestone: 2.3
Component: General Version: 2.2
Severity: normal Keywords:
Cc:

Description

line232:

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

line240:

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

A doubloon no?

Attachments

4251.diff (3.5 kB) - added by rob1n on 05/12/07 19:28:45.

Change History

05/12/07 14:15:28 changed by momo360modena

doubloon => double entry..

05/12/07 16:26:34 changed by rob1n

  • status changed from new to closed.
  • resolution set to invalid.
  • milestone deleted.

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

05/12/07 18:04:08 changed by momo360modena

  • status changed from closed to reopened.
  • resolution deleted.

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 " ;

05/12/07 19:23:11 changed by rob1n

  • owner changed from anonymous to rob1n.
  • status changed from reopened to new.
  • milestone set to 2.4.

My misunderstanding. I'll look into this.

05/12/07 19:28:45 changed by rob1n

  • attachment 4251.diff added.

05/12/07 19:29:30 changed by rob1n

  • priority changed from high to normal.
  • status changed from new to assigned.
  • severity changed from minor to normal.
  • milestone changed from 2.4 to 2.3.

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.

05/12/07 19:47:47 changed by rob1n

  • status changed from assigned to closed.
  • resolution set to fixed.

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

05/12/07 21:05:26 changed by momo360modena

Thanks ;)