Make WordPress Core

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#39682 closed enhancement (duplicate)

WP_Query: Small fix for 'post__in' argument showing all results if empty array is passed

Reported by: edonramadani's profile edonramadani Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.7
Component: Query Keywords:
Focuses: Cc:

Description

When an empty array is passed to

$args['posts__in']

it should return no results instead of all posts.
File: wp-includes/class-wp-query.php @line 1956

} elseif ( $q['post__in'] ) {
    if(count($q['posts__in']) > 0){
        $post__in = implode(',', array_map( 'absint', $q['post__in'] ));
    } else {
        $post__in = NULL;
    }
    $where .= " AND {$wpdb->posts}.ID IN ($post__in)";
}

Change History (3)

#1 @edonramadani
8 years ago

  • Keywords needs-testing added

#2 @swissspidy
8 years ago

  • Keywords needs-testing removed
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Hey there,

Welcome to WordPress Trac! This was previously reported in #28099 and #12212 and it was decided to not change this behaviour because of backward compatibility concerns.

#3 @edonramadani
8 years ago

Hello there,

Thank you for your reply, and thank you for welcoming me to WordPress Trac!
I did not see the decision to not change this because of backward compatibility concerns, I apologize.

Note: See TracTickets for help on using tickets.