Make WordPress Core


Ignore:
Timestamp:
12/01/2025 03:31:41 PM (9 months ago)
Author:
SergeyBiryukov
Message:

Notes: Avoid incrementing comment_count when notes are resolved or reopened.

Follow-up to [60987].

Props hbhalodia, wildworks, shimotomoki, gulamdastgir04, JeffPaul, ellatrix, SergeyBiryukov.
Fixes #64325.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/comment/wpUpdateCommentCountNow.php

    r56971 r61336  
    4747        }
    4848
     49        /**
     50        * @ticket 64325
     51        */
     52        public function test_only_approved_regular_comments_are_counted() {
     53                $post_id = self::factory()->post->create();
     54
     55                self::factory()->comment->create(
     56                        array(
     57                                'comment_post_ID'  => $post_id,
     58                                'comment_approved' => 0,
     59                        )
     60                );
     61                self::factory()->comment->create(
     62                        array(
     63                                'comment_post_ID'  => $post_id,
     64                                'comment_approved' => 1,
     65                        )
     66                );
     67                self::factory()->comment->create(
     68                        array(
     69                                'comment_post_ID'  => $post_id,
     70                                'comment_type'     => 'note',
     71                                'comment_approved' => 0,
     72                        )
     73                );
     74                self::factory()->comment->create(
     75                        array(
     76                                'comment_post_ID'  => $post_id,
     77                                'comment_type'     => 'note',
     78                                'comment_approved' => 1,
     79                        )
     80                );
     81
     82                $this->assertTrue( wp_update_comment_count_now( $post_id ) );
     83                $this->assertSame( '1', get_comments_number( $post_id ) );
     84        }
     85
    4986        public function _return_100() {
    5087                return 100;
Note: See TracChangeset for help on using the changeset viewer.