From 63e9eb7e5ed8b9eb06cebfab24a18904fb7c4f6a Mon Sep 17 00:00:00 2001 From: Rachel Baker Date: Fri, 15 Jan 2016 20:09:08 +0000 Subject: [PATCH] Comments: Use TEXT column type in fallback for `wp_get_comment_column_max_length()`. Fixes #10377. git-svn-id: https://develop.svn.wordpress.org/trunk@36325 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/comment.php | 3 ++- tests/phpunit/tests/comment.php | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php index 41a2260503..3d1439a8a7 100644 --- a/src/wp-includes/comment.php +++ b/src/wp-includes/comment.php @@ -966,7 +966,8 @@ function wp_get_comment_column_max_length( $column ) { } elseif ( is_array( $col_length ) && isset( $col_length['length'] ) && intval( $col_length['length'] ) > 0 ) { $max_length = (int) $col_length['length']; } else { - $max_length = 255; + // Assume a TEXT column, 65535 - 10. + $max_length = 65525; } if ( ! empty( $col_length['type'] ) && 'byte' === $col_length['type'] ) { diff --git a/tests/phpunit/tests/comment.php b/tests/phpunit/tests/comment.php index e4f50b1fe6..2e1d87ec90 100644 --- a/tests/phpunit/tests/comment.php +++ b/tests/phpunit/tests/comment.php @@ -672,4 +672,22 @@ class Tests_Comment extends WP_UnitTestCase { $this->assertSame( '111.111.1.1', $updated->comment_author_IP ); $this->assertSame( 'SHIELD_AGENT', $updated->comment_agent ); } + + public function test_wp_get_comment_column_max_length() { + $columns = array( + 'comment_author' => 245, + 'comment_author_email' => 100, + 'comment_author_url' => 200, + 'comment_author_IP' => 100, + 'comment_content' => 65525, + 'comment_approved' => 20, + 'comment_agent' => 255, + 'comment_type' => 20, + ); + + foreach ( $columns as $column => $expected ) { + $max_length = wp_get_comment_column_max_length( $column ); + $this->assertSame( $expected, $max_length ); + } + } }