Make WordPress Core

Ticket #35513: 35513.1.diff

File 35513.1.diff, 1.8 KB (added by danielbachhuber, 8 years ago)
  • src/wp-includes/class-wp-comment-query.php

    diff --git a/src/wp-includes/class-wp-comment-query.php b/src/wp-includes/class-wp-comment-query.php
    index ccbf10c..a120b58 100644
    a b class WP_Comment_Query { 
    745745                        $this->sql_clauses['where']['user_id'] = $wpdb->prepare( 'user_id = %d', $this->query_vars['user_id'] );
    746746                }
    747747
    748                 if ( '' !== $this->query_vars['search'] ) {
     748                if ( ! in_array( $this->query_vars['search'], array( '', null, false ), true ) ) {
    749749                        $search_sql = $this->get_search_sql(
    750750                                $this->query_vars['search'],
    751751                                array( 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_content' )
  • tests/phpunit/tests/comment/query.php

    diff --git a/tests/phpunit/tests/comment/query.php b/tests/phpunit/tests/comment/query.php
    index 88fe55e..e787dfc 100644
    a b class Tests_Comment_Query extends WP_UnitTestCase { 
    11421142                $this->assertEqualSets( array( $c1, $c2, $c3, $c4, $c5 ), $found );
    11431143        }
    11441144
     1145        public function test_search_falsy_arg() {
     1146                $q = new WP_Comment_Query();
     1147                $q->query( array(
     1148                        'search' => false,
     1149                ) );
     1150                $this->assertNotContains( "comment_author LIKE '%%'", $q->request );
     1151                $q->query( array(
     1152                        'search' => null,
     1153                ) );
     1154                $this->assertNotContains( "comment_author LIKE '%%'", $q->request );
     1155                $q->query( array(
     1156                        'search' => '',
     1157                ) );
     1158                $this->assertNotContains( "comment_author LIKE '%%'", $q->request );
     1159                $q->query( array(
     1160                        'search' => 'foo',
     1161                ) );
     1162                $this->assertContains( "comment_author LIKE '%foo%'", $q->request );
     1163                $q->query( array(
     1164                        'search' => '0',
     1165                ) );
     1166                $this->assertContains( "comment_author LIKE '%0%'", $q->request );
     1167        }
     1168
    11451169        public function test_orderby_default() {
    11461170                global $wpdb;
    11471171