Ticket #4251 (closed defect (bug): fixed)

Opened 5 years ago

Last modified 5 years ago

Small error in get_posts not?

Reported by: momo360modena Owned by: 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 Download (3.5 KB) - added by rob1n 5 years ago.

Change History

doubloon => double entry..

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

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

  • Status changed from closed to reopened
  • Resolution invalid 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 " ;
  • Owner changed from anonymous to rob1n
  • Status changed from reopened to new
  • Milestone set to 2.4

My misunderstanding. I'll look into this.

rob1n5 years ago

  • 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.

  • 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

Thanks ;)

Note: See TracTickets for help on using tickets.