Ticket #48027: 48027.1.diff
File 48027.1.diff, 4.0 KB (added by , 6 years ago) |
---|
-
src/wp-includes/class-wp-comment.php
diff --git src/wp-includes/class-wp-comment.php src/wp-includes/class-wp-comment.php index f631444f8f..628aaf3082 100644
final class WP_Comment { 162 162 * Retrieves a WP_Comment instance. 163 163 * 164 164 * @since 4.4.0 165 * @since 5.3.0 Convert WP_Comment::$user_id to int. 165 166 * 166 167 * @global wpdb $wpdb WordPress database abstraction object. 167 168 * … … final class WP_Comment { 188 189 wp_cache_add( $_comment->comment_ID, $_comment, 'comment' ); 189 190 } 190 191 192 $_comment->user_id = ( int ) $_comment->user_id; 193 191 194 return new WP_Comment( $_comment ); 192 195 } 193 196 -
tests/phpunit/tests/comment-submission.php
diff --git tests/phpunit/tests/comment-submission.php tests/phpunit/tests/comment-submission.php index 2ad7f49bf5..760747ab8f 100644
class Tests_Comment_Submission extends WP_UnitTestCase { 246 246 $this->assertSame( 'Comment Author', $comment->comment_author ); 247 247 $this->assertSame( 'comment@example.org', $comment->comment_author_email ); 248 248 $this->assertSame( 'http://user.example.org', $comment->comment_author_url ); 249 $this->assertSame( '0', $comment->user_id );249 $this->assertSame( 0, $comment->user_id ); 250 250 251 251 } 252 252 -
tests/phpunit/tests/comment.php
diff --git tests/phpunit/tests/comment.php tests/phpunit/tests/comment.php index 720a805062..bb21adfe88 100644
class Tests_Comment extends WP_UnitTestCase { 855 855 856 856 $expected = array( 857 857 'comment_ID' => (string) $comment_id, 858 'user_id' => '0', // Anonymized.858 'user_id' => 0, // Anonymized. 859 859 'comment_author' => 'Anonymous', // Anonymized. 860 860 'comment_author_email' => '', // Anonymized. 861 861 'comment_author_url' => '', // Anonymized. … … class Tests_Comment extends WP_UnitTestCase { 1241 1241 // Number of exported comments. 1242 1242 $this->assertSame( 0, count( $actual['data'] ) ); 1243 1243 } 1244 1245 /** 1246 * @ticket 48027 1247 */ 1248 public function test_user_id_from_get_comment_should_be_int() { 1249 $args = array( 1250 'user_id' => self::$user_id, 1251 'comment_post_ID' => self::$post_id, 1252 'comment_author' => 'Comment Author', 1253 'comment_author_email' => 'personal@local.host', 1254 'comment_author_url' => 'https://local.host/', 1255 'comment_author_IP' => '192.168.0.1', 1256 'comment_date' => '2018-03-28 20:05:00', 1257 'comment_agent' => 'SOME_AGENT', 1258 'comment_content' => 'Comment', 1259 ); 1260 1261 $c = self::factory()->comment->create( $args ); 1262 1263 $comment = get_comment( $c ); 1264 $this->assertSame( $comment->user_id, self::$user_id ); 1265 1266 // Test for get_comments(). 1267 $user_id_1 = self::factory()->user->create(); 1268 $user_id_2 = self::factory()->user->create(); 1269 $user_id_3 = self::factory()->user->create(); 1270 self::factory()->comment->create( array( 'user_id' => $user_id_1, 'comment_post_ID' => self::$post_id ) ); 1271 self::factory()->comment->create( array( 'user_id' => $user_id_2, 'comment_post_ID' => self::$post_id ) ); 1272 self::factory()->comment->create( array( 'user_id' => $user_id_3, 'comment_post_ID' => self::$post_id ) ); 1273 1274 $comments = get_comments( array( 'post_id' => self::$post_id ) ); 1275 1276 foreach( $comments as $comm ) { 1277 $this->assertInternalType( 'int', $comm->user_id ); 1278 } 1279 } 1244 1280 } -
tests/phpunit/tests/xmlrpc/wp/getComment.php
diff --git tests/phpunit/tests/xmlrpc/wp/getComment.php tests/phpunit/tests/xmlrpc/wp/getComment.php index 200f71ec53..ad2f6aa079 100644
class Tests_XMLRPC_wp_getComment extends WP_XMLRPC_UnitTestCase { 54 54 $this->assertNotIXRError( $result ); 55 55 56 56 // Check data types 57 $this->assertInternalType( ' string', $result['user_id'] );57 $this->assertInternalType( 'int', $result['user_id'] ); 58 58 $this->assertInternalType( 'string', $result['comment_id'] ); 59 59 $this->assertInstanceOf( 'IXR_Date', $result['date_created_gmt'] ); 60 60 $this->assertInternalType( 'string', $result['parent'] );