Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/wp-admin/includes/schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ function wp_get_db_schema( $scope = 'all', $blog_id = null ) {
*/
$max_index_length = 191;

/*
* comment_post_ID_parent_content indexes comment_content after two bigint columns.
* Limit the content prefix to floor( ( 767 - 16 - 2 ) / 4 ) = 187 characters,
* keeping the composite key below the 767-byte limit.
*/
$max_comment_content_index_length = 187;

// Blog-specific tables.
$blog_tables = "CREATE TABLE $wpdb->termmeta (
meta_id bigint(20) unsigned NOT NULL auto_increment,
Expand Down Expand Up @@ -116,6 +123,7 @@ function wp_get_db_schema( $scope = 'all', $blog_id = null ) {
user_id bigint(20) unsigned NOT NULL default '0',
PRIMARY KEY (comment_ID),
KEY comment_post_ID (comment_post_ID),
KEY comment_post_ID_parent_content (comment_post_ID,comment_parent,comment_content($max_comment_content_index_length)),
KEY comment_approved_date_gmt (comment_approved,comment_date_gmt),
KEY comment_date_gmt (comment_date_gmt),
KEY comment_parent (comment_parent),
Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*
* @global int $wp_db_version
*/
$wp_db_version = 61833;
$wp_db_version = 61834;

/**
* Holds the TinyMCE version.
Expand Down
37 changes: 37 additions & 0 deletions tests/phpunit/tests/comment/wpAllowComment.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,41 @@ public function test_die_as_duplicate_if_comment_author_name_and_emails_match()

$result = wp_allow_comment( $comment_data );
}

/**
* @ticket 26858
*/
public function test_return_error_as_duplicate_if_comment_author_email_is_empty() {
$comment_id = self::factory()->comment->create(
array(
'comment_post_ID' => self::$post_id,
'comment_approved' => '1',
'comment_author' => 'Anonymous Bob',
'comment_author_email' => '',
'comment_author_url' => 'http://example.com',
'comment_content' => 'Still a duplicate.',
)
);

$now = time();
$comment_data = array(
'comment_post_ID' => self::$post_id,
'comment_author' => 'Anonymous Bob',
'comment_author_email' => '',
'comment_author_url' => 'http://example.com',
'comment_content' => 'Still a duplicate.',
'comment_author_IP' => '192.168.0.1',
'comment_parent' => 0,
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now ),
'comment_agent' => 'Bobbot/2.1',
'comment_type' => '',
);

$result = wp_allow_comment( $comment_data, true );

wp_delete_comment( $comment_id, true );

$this->assertWPError( $result );
$this->assertSame( 'comment_duplicate', $result->get_error_code() );
}
}
Loading