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
This commit is contained in:
Rachel Baker 2016-01-15 20:09:08 +00:00
parent 50068ee5b9
commit 63e9eb7e5e
2 changed files with 20 additions and 1 deletions

View File

@ -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'] ) {

View File

@ -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 );
}
}
}