Changeset 36480
- Timestamp:
- 02/05/2016 06:49:46 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-comments-list-table.php
r36387 r36480 34 34 * @see WP_List_Table::__construct() for more information on default arguments. 35 35 * 36 * @global int |bool$post_id36 * @global int $post_id 37 37 * 38 38 * @param array $args An associative array of arguments. … … 41 41 global $post_id; 42 42 43 $post_id = isset( $_REQUEST['p'] ) ? absint( $_REQUEST['p'] ) : false;43 $post_id = isset( $_REQUEST['p'] ) ? absint( $_REQUEST['p'] ) : 0; 44 44 45 45 if ( get_option( 'show_avatars' ) ) { … … 70 70 /** 71 71 * 72 * @global int |bool$post_id72 * @global int $post_id 73 73 * @global string $comment_status 74 74 * @global string $search … … 193 193 /** 194 194 * 195 * @global int |bool$post_id195 * @global int $post_id 196 196 * @global string $comment_status 197 197 * @global string $comment_type … … 384 384 /** 385 385 * 386 * @global int |bool$post_id386 * @global int $post_id 387 387 * 388 388 * @return array -
trunk/src/wp-includes/class-wp-comment-query.php
r36479 r36480 215 215 * @type int $post_ID Currently unused. 216 216 * @type int $post_id Limit results to those affiliated with a given post ID. 217 * Default null.217 * Default 0. 218 218 * @type array $post__in Array of post IDs to include affiliated comments for. 219 219 * Default empty. … … 279 279 'post_author__not_in' => '', 280 280 'post_ID' => '', 281 'post_id' => null,281 'post_id' => 0, 282 282 'post__in' => '', 283 283 'post__not_in' => '', … … 648 648 } 649 649 650 if ( strlen( $this->query_vars['post_id'] ) ) { 651 $this->sql_clauses['where']['post_id'] = $wpdb->prepare( 'comment_post_ID = %d', $this->query_vars['post_id'] ); 650 $post_id = absint( $this->query_vars['post_id'] ); 651 if ( ! empty( $post_id ) ) { 652 $this->sql_clauses['where']['post_id'] = $wpdb->prepare( 'comment_post_ID = %d', $post_id ); 652 653 } 653 654 -
trunk/tests/phpunit/tests/comment/query.php
r36479 r36480 37 37 } 38 38 39 /** 40 * @ticket 35090 41 */ 42 public function test_post_id_0_should_return_comments_with_no_parent() { 43 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 44 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => 0, 'comment_approved' => '1' ) ); 39 public function test_query_post_id_0() { 40 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 45 41 46 42 $q = new WP_Comment_Query(); … … 50 46 ) ); 51 47 52 $this->assertEqualSets( array( $c2 ), $found ); 53 } 54 55 /** 56 * @ticket 35090 57 */ 58 public function test_post_id_string_0_should_return_comments_with_no_parent() { 59 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 60 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => 0, 'comment_approved' => '1' ) ); 61 62 $q = new WP_Comment_Query(); 63 $found = $q->query( array( 64 'post_id' => '0', 65 'fields' => 'ids', 66 ) ); 67 68 $this->assertEqualSets( array( $c2 ), $found ); 69 } 70 71 /** 72 * @ticket 35090 73 */ 74 public function test_post_id_null_should_be_ignored() { 75 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 76 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => 0, 'comment_approved' => '1' ) ); 77 78 $q = new WP_Comment_Query(); 79 $found = $q->query( array( 80 'post_id' => null, 81 'fields' => 'ids', 82 ) ); 83 84 $this->assertEqualSets( array( $c1, $c2 ), $found ); 85 } 86 87 /** 88 * @ticket 35090 89 */ 90 public function test_post_id_false_should_be_ignored() { 91 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 92 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => 0, 'comment_approved' => '1' ) ); 93 94 $q = new WP_Comment_Query(); 95 $found = $q->query( array( 96 'post_id' => false, 97 'fields' => 'ids', 98 ) ); 99 100 $this->assertEqualSets( array( $c1, $c2 ), $found ); 101 } 102 103 /** 104 * @ticket 35090 105 */ 106 public function test_post_id_empty_string_should_be_ignored() { 107 $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); 108 $c2 = self::factory()->comment->create( array( 'comment_post_ID' => 0, 'comment_approved' => '1' ) ); 109 110 $q = new WP_Comment_Query(); 111 $found = $q->query( array( 112 'post_id' => '', 113 'fields' => 'ids', 114 ) ); 115 116 $this->assertEqualSets( array( $c1, $c2 ), $found ); 48 $this->assertEqualSets( array( $c1 ), $found ); 117 49 } 118 50
Note: See TracChangeset
for help on using the changeset viewer.