mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-05 21:24:35 +00:00
Allow comment_exists() to match based on GMT date.
The `comment_date_gmt` field of the `wp_comments` table is indexed, which makes `WHERE` matches against the field much faster than against the unindexed `comment_date`. For bulk operations like data import, the speed difference can be meaningful. We continue to default to 'blog' for `$timezone`, to preserve compatibility with existing uses. Props apokalyptik. Fixes #33871. git-svn-id: https://develop.svn.wordpress.org/trunk@34460 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -23,4 +23,64 @@ class Tests_Admin_IncludesComment extends WP_UnitTestCase {
|
||||
$this->assertNull( comment_exists( 1, '2004-01-02 12:00:00' ) );
|
||||
$this->assertEquals( $p1, comment_exists( 1, '2014-05-06 12:00:00' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 33871
|
||||
*/
|
||||
public function test_default_value_of_timezone_should_be_blog() {
|
||||
$p = $this->factory->post->create();
|
||||
$c = $this->factory->comment->create( array(
|
||||
'comment_author' => 1,
|
||||
'comment_post_ID' => $p,
|
||||
'comment_date' => '2014-05-06 12:00:00',
|
||||
'comment_date_gmt' => '2014-05-06 07:00:00',
|
||||
) );
|
||||
|
||||
$this->assertEquals( $p, comment_exists( 1, '2014-05-06 12:00:00' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 33871
|
||||
*/
|
||||
public function test_should_respect_timezone_blog() {
|
||||
$p = $this->factory->post->create();
|
||||
$c = $this->factory->comment->create( array(
|
||||
'comment_author' => 1,
|
||||
'comment_post_ID' => $p,
|
||||
'comment_date' => '2014-05-06 12:00:00',
|
||||
'comment_date_gmt' => '2014-05-06 07:00:00',
|
||||
) );
|
||||
|
||||
$this->assertEquals( $p, comment_exists( 1, '2014-05-06 12:00:00', 'blog' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 33871
|
||||
*/
|
||||
public function test_should_respect_timezone_gmt() {
|
||||
$p = $this->factory->post->create();
|
||||
$c = $this->factory->comment->create( array(
|
||||
'comment_author' => 1,
|
||||
'comment_post_ID' => $p,
|
||||
'comment_date' => '2014-05-06 12:00:00',
|
||||
'comment_date_gmt' => '2014-05-06 07:00:00',
|
||||
) );
|
||||
|
||||
$this->assertEquals( $p, comment_exists( 1, '2014-05-06 07:00:00', 'gmt' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 33871
|
||||
*/
|
||||
public function test_invalid_timezone_should_fall_back_on_blog() {
|
||||
$p = $this->factory->post->create();
|
||||
$c = $this->factory->comment->create( array(
|
||||
'comment_author' => 1,
|
||||
'comment_post_ID' => $p,
|
||||
'comment_date' => '2014-05-06 12:00:00',
|
||||
'comment_date_gmt' => '2014-05-06 07:00:00',
|
||||
) );
|
||||
|
||||
$this->assertEquals( $p, comment_exists( 1, '2014-05-06 12:00:00', 'not_a_valid_value' ) );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user