WordPress.org

Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#20572 closed defect (bug) (fixed)

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

Reported by: insertvisionhere Owned by: jaap@…
Milestone: 3.4 Priority: normal
Severity: normal Version:
Component: Comments Keywords: has-patch
Focuses: 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 10 years ago.
The file in question with my patch applied

Download all attachments as: .zip

Change History (3)

@insertvisionhere
10 years ago

The file in question with my patch applied

#1 @nacin
10 years ago

  • Milestone changed from Awaiting Review to 3.4

#2 @nacin
10 years ago

  • 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.