WordPress.org

Make WordPress Core

Changeset 30093


Ignore:
Timestamp:
10/29/2014 07:50:31 PM (7 years ago)
Author:
boonebgorges
Message:

Support an empty string passed as a status in WP_Comment_Query.

The changes in [30084] broke backward compatibility with interfaces that
manually passed an empty string for the value of 'status', such as on
wp-admin/edit-comments.php.

Fixes #29612.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/comment.php

    r30084 r30093  
    356356        }
    357357
    358         // Remove empty statuses.
    359         $statuses = array_filter( $statuses );
    360 
    361358        // 'any' overrides other statuses.
    362359        if ( ! in_array( 'any', $statuses ) ) {
     
    372369
    373370                    case 'all' :
     371                    case '' :
    374372                        $status_clauses[] = "( comment_approved = '0' OR comment_approved = '1' )";
    375373                        break;
  • trunk/tests/phpunit/tests/comment/query.php

    r30084 r30093  
    1414
    1515        $this->post_id = $this->factory->post->create();
     16    }
     17
     18    /**
     19     * @ticket 29612
     20     */
     21    public function test_status_empty_string() {
     22        $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
     23        $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) );
     24        $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'spam' ) );
     25
     26        $q = new WP_Comment_Query();
     27        $found = $q->query( array(
     28            'status' => '',
     29            'fields' => 'ids',
     30        ) );
     31
     32        $this->assertEqualSets( array( $c1, $c2 ), $found );
    1633    }
    1734
Note: See TracChangeset for help on using the changeset viewer.