Ticket #21663: 21663.14.diff
File 21663.14.diff, 3.1 KB (added by , 11 years ago) |
---|
-
src/wp-includes/comment.php
373 373 } 374 374 if ( '' !== $parent ) 375 375 $where .= $wpdb->prepare( ' AND comment_parent = %d', $parent ); 376 if ( '' !== $user_id ) 376 377 if ( is_array( $user_id ) ) { 378 $where .= ' AND user_id IN (' . implode( ',', array_map( 'absint', $user_id ) ) . ')'; 379 } elseif ( '' !== $user_id ) { 377 380 $where .= $wpdb->prepare( ' AND user_id = %d', $user_id ); 381 } 382 378 383 if ( '' !== $search ) 379 384 $where .= $this->get_search_sql( $search, array( 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_content' ) ); 380 385 -
src/wp-includes/wp-db.php
569 569 $this->show_errors(); 570 570 571 571 /* Use ext/mysqli if it exists and: 572 * - USE_EXT_MYSQL is defined as false, or 572 573 * - We are a development version of WordPress, or 573 574 * - We are running PHP 5.5 or greater, or 574 575 * - ext/mysql is not loaded. 575 576 */ 576 577 if ( function_exists( 'mysqli_connect' ) ) { 577 if ( version_compare( phpversion(), '5.5', '>=' ) || ! function_exists( 'mysql_connect' ) ) { 578 if ( defined( 'USE_EXT_MYSQL' ) ) { 579 $this->use_mysqli = ! USE_EXT_MYSQL; 580 } elseif ( version_compare( phpversion(), '5.5', '>=' ) || ! function_exists( 'mysql_connect' ) ) { 578 581 $this->use_mysqli = true; 579 582 } elseif ( false !== strpos( $GLOBALS['wp_version'], '-' ) ) { 580 583 $this->use_mysqli = true; -
tests/phpunit/tests/comment/query.php
156 156 $this->assertEquals( 10, count( get_comments( array( 'status' => 'trash' ) ) ) ); 157 157 $this->assertEquals( 10, count( get_comments( array( 'status' => 'spam' ) ) ) ); 158 158 } 159 160 /** 161 * @ticket 27064 162 */ 163 function test_get_comments_by_user() { 164 $users = $this->factory->user->create_many( 2 ); 165 $this->factory->comment->create( array( 'user_id' => $users[0], 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); 166 $this->factory->comment->create( array( 'user_id' => $users[0], 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); 167 $this->factory->comment->create( array( 'user_id' => $users[1], 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); 168 169 $comments = get_comments( array( 'user_id' => $users[0] ) ); 170 171 $this->assertCount( 2, $comments ); 172 $this->assertEquals( $users[0], $comments[0]->user_id ); 173 $this->assertEquals( $users[0], $comments[1]->user_id ); 174 175 $comments = get_comments( array( 'user_id' => $users ) ); 176 177 $this->assertCount( 3, $comments ); 178 $this->assertEquals( $users[0], $comments[0]->user_id ); 179 $this->assertEquals( $users[0], $comments[1]->user_id ); 180 $this->assertEquals( $users[1], $comments[2]->user_id ); 181 182 } 159 183 }