Make WordPress Core

Ticket #25523: 25523.diff

File 25523.diff, 1.9 KB (added by wonderboymusic, 11 years ago)
  • src/wp-includes/query.php

     
    27562756                                foreach ( $statuswheres as $index => $statuswhere )
    27572757                                        $statuswheres[$index] = "($statuswhere OR ($wpdb->posts.post_status = 'inherit' AND " . str_replace($wpdb->posts, 'p2', $statuswhere) . "))";
    27582758                        }
    2759                         foreach ( $statuswheres as $statuswhere )
    2760                                 $where .= " AND $statuswhere";
     2759                        $where_status = implode( ' OR ', $statuswheres );
     2760                        if ( ! empty( $where_status ) ) {
     2761                                $where .= " AND ($where_status)";
     2762                        }
    27612763                } elseif ( !$this->is_singular ) {
    27622764                        $where .= " AND ($wpdb->posts.post_status = 'publish'";
    27632765
  • tests/phpunit/tests/query/results.php

     
    533533                $this->assertFalse( $this->q->is_month );
    534534                $this->assertFalse( $this->q->is_year );
    535535        }
     536
     537        function test_perm_with_status_array() {
     538                global $wpdb;
     539                $this->q->query( array( 'perm' => 'readable', 'post_status' => array( 'publish', 'private' ) ) );
     540                $this->assertTrue( $this->q->have_posts() );
     541                $this->assertContains( "(({$wpdb->posts}.post_status = 'publish') OR ({$wpdb->posts}.post_author = 0 AND ({$wpdb->posts}.post_status = 'private')))",
     542                        $this->q->request
     543                );
     544                $this->assertNotContains( "({$wpdb->posts}.post_status = 'publish') AND", $this->q->request );
     545        }
    536546}
  • tests/phpunit/tests/query.php

     
    7676                        $first_query->reset_postdata();
    7777                        $this->assertEquals( get_the_ID(), $post_id );
    7878                }
    79 
    8079        }
    8180}
    82  No newline at end of file