#20572 closed defect (bug) (fixed)

wp-includes/comment-template:comment_form() calling comment_open() without passing $post_id

Reported by: insertvisionhere Owned by: jaap@…
Priority: normal Milestone: 3.4
Component: Comments Version:
Severity: normal Keywords: has-patch
Cc:

Description

Although you can pass a post_id to wp-includes/comment-template:comment_form()in order to specify which post to add a comment form to, on line 1553 this function calls if( comments_open() ) but doesn't pass it through the post_id argument.

I encountered this bug by using ajax to call a page with a custom post type from a standard page. The page called via ajax calls comments_template() which in turn calls comment_form() and passes it the post_id of the ajax page, however that post_id doesn't make it to comments_open() meaning it searches for comment status on the standard page and not the page called through ajax.

This can be fixed by changing <?php if ( comments_open() ) : ?> on line 1553 to <?php if ( comments_open($post_id) ) : ?>

Attachments (1)

comment-template.php (53.3 KB) - added by insertvisionhere 13 months ago.
The file in question with my patch applied

Download all attachments as: .zip

Change History (3)

The file in question with my patch applied

  • Milestone changed from Awaiting Review to 3.4
  • Resolution set to fixed
  • Status changed from new to closed

In [20641]:

In comment_form(), pass the $post_id to comments_open(). props insertvisionhere. fixes #20572.

Note: See TracTickets for help on using tickets.