mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-03-31 18:54:29 +00:00
Comments: Show the "awaiting moderation" message when comment cookies are disabled.
The "Your comment is awaiting moderation." message relied upon the comment author cookie being set. However, since it's now possible to opt-out of that cookie, submitting a comment won't show the comment preview when the comment is placed in moderation. To avoid this issue, we now include a hash in the redirect URL, allowing the site to identify that a preview of the moderated comment should be displayed. Props imath, tomdxw, birgire, lakenh, azaozz, pento. Fixes #43857. git-svn-id: https://develop.svn.wordpress.org/trunk@44659 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -831,6 +831,42 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
|
||||
return $commenter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 43857
|
||||
*/
|
||||
public function test_comments_list_should_include_just_posted_unapproved_comment() {
|
||||
$now = time();
|
||||
$p = self::factory()->post->create();
|
||||
$c = self::factory()->comment->create(
|
||||
array(
|
||||
'comment_post_ID' => $p,
|
||||
'comment_content' => '1',
|
||||
'comment_approved' => '0',
|
||||
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ),
|
||||
'comment_author_email' => 'foo@bar.mail',
|
||||
)
|
||||
);
|
||||
$comment = get_comment( $c );
|
||||
|
||||
$this->go_to(
|
||||
add_query_arg(
|
||||
array(
|
||||
'unapproved' => $comment->comment_ID,
|
||||
'moderation-hash' => wp_hash( $comment->comment_date_gmt ),
|
||||
),
|
||||
get_comment_link( $comment )
|
||||
)
|
||||
);
|
||||
|
||||
$found = get_echo( 'comments_template' );
|
||||
|
||||
// Find the found comment in the markup.
|
||||
preg_match( '|id="comment-([0-9]+)|', $found, $matches );
|
||||
|
||||
$found_cid = (int) $matches[1];
|
||||
$this->assertSame( $c, $found_cid );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 35378
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user