Skip to content

Commit 92f1cbe

Browse files
committed
Prepare anti-spam entry processing for WP Comments and Blocksy.
1 parent 80dd57e commit 92f1cbe

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/php/Abstracts/CommentBase.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,11 @@ private function invalid_captcha_error( $approved, string $error_message = '' )
157157
* @return array
158158
*/
159159
private function get_entry( array $comment_data ): array {
160+
$post_id = $comment_data['comment_post_ID'];
161+
$post = get_post( $post_id );
162+
160163
return [
161-
'form_date_gmt' => gmdate( 'Y-m-d H:i:s' ),
164+
'form_date_gmt' => $post->post_modified_gmt ?? null,
162165
'data' => [
163166
'name' => $comment_data['comment_author'],
164167
'email' => $comment_data['comment_author_email'],

tests/php/integration/WP/CommentTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ public function test_add_captcha_when_NOT_active(): void {
205205
*/
206206
public function test_verify(): void {
207207
$comment_data = [
208+
'comment_post_ID' => 5,
208209
'comment_author' => 'Some author',
209210
'comment_author_email' => '[email protected]',
210211
'comment_author_url' => 'https://some.com/author',
@@ -272,6 +273,7 @@ static function () {
272273
*/
273274
public function test_verify_not_verified(): void {
274275
$comment_data = [
276+
'comment_post_ID' => 5,
275277
'comment_author' => 'Some author',
276278
'comment_author_email' => '[email protected]',
277279
'comment_author_url' => 'https://some.com/author',
@@ -298,6 +300,7 @@ public function test_verify_not_verified(): void {
298300
*/
299301
public function test_verify_signature_valid_returns_early(): void {
300302
$comment_data = [
303+
'comment_post_ID' => 5,
301304
'comment_author' => 'Some author',
302305
'comment_author_email' => '[email protected]',
303306
'comment_author_url' => 'https://some.com/author',
@@ -333,6 +336,7 @@ static function () {
333336
*/
334337
public function test_verify_signature_invalid_sets_bad_signature(): void {
335338
$comment_data = [
339+
'comment_post_ID' => 5,
336340
'comment_author' => 'Some author',
337341
'comment_author_email' => '[email protected]',
338342
'comment_author_url' => 'https://some.com/author',

0 commit comments

Comments
 (0)