Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#32312 closed defect (bug) (fixed)

Post Comment button disappeared in some themes

Reported by: sergeybiryukov's profile SergeyBiryukov Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 4.2.3 Priority: normal
Severity: normal Version: 4.2
Component: Comments Keywords: has-patch commit fixed-major
Focuses: Cc:

Description (last modified by SergeyBiryukov)

[31699] caused the Post Comment button to disappear in some themes.

As reported by @tellyworth in 33:ticket:15015:

Just FYI we've come across a handful of themes that were affected by this. They were filtering comment_form_defaults and building a fresh $args array from scratch, so the new submit elements were not included in the return. That left them with no Submit Comment button.

Seeing some similar reports on support forums. Here's an example in My Life theme.

We should make sure that 'submit_button' and 'submit_field' are still in the array after it's filtered.

Attachments (1)

32312.diff (2.0 KB) - added by boonebgorges 8 years ago.

Download all attachments as: .zip

Change History (10)

#1 @SergeyBiryukov
8 years ago

  • Description modified (diff)
  • Summary changed from Comment button disappeared in some themes to Post Comment button disappeared in some themes

@boonebgorges
8 years ago

#2 follow-ups: @boonebgorges
8 years ago

  • Keywords has-patch 2nd-opinion added; needs-patch removed

We should make sure that 'submit_button' and 'submit_field' are still in the array after it's filtered.

32312.diff enforces this for *all* default values. This seems like a more general solution for this problem. The only backward compatibility concern would be isset() checks expecting a given array key to be missing after filtering the default arguments. I don't see anything like that in comment_form(), and $args is never passed to a hook that might do a similar trick, but it would be nice to get another set of eyes.

#3 @obenland
8 years ago

  • Owner set to SergeyBiryukov
  • Status changed from new to assigned

#4 in reply to: ↑ description @anneastrid15
8 years ago

I have that same problem with the Origin Theme. Please fix in next WP update.

#5 in reply to: ↑ 2 @SergeyBiryukov
8 years ago

Replying to boonebgorges:

The only backward compatibility concern would be isset() checks expecting a given array key to be missing after filtering the default arguments. I don't see anything like that in comment_form(), and $args is never passed to a hook that might do a similar trick, but it would be nice to get another set of eyes.

This would no longer work with the array_merge():

function mytheme_comments_form_defaults( $defaults ) {
	unset( $defaults['comment_notes_after'] );
	return $defaults;
}
add_filter( 'comment_form_defaults', 'mytheme_comments_form_defaults' );

But it currently produces a notice anyway, and there's a more correct way to do it:

function mytheme_comments_form_defaults( $defaults ) {
	$defaults['comment_notes_after'] = '';
	return $defaults;
}
add_filter( 'comment_form_defaults', 'mytheme_comments_form_defaults' );

So I'd suggest going with your fix.

#6 @SergeyBiryukov
8 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 32511:

In comment_form(), ensure that filtered arguments contain all required default values.

props boonebgorges.
fixes #32312 for trunk.

#7 @SergeyBiryukov
8 years ago

  • Keywords commit fixed-major added; 2nd-opinion removed
  • Resolution fixed deleted
  • Status changed from closed to reopened

#8 in reply to: ↑ 2 @jonna
8 years ago

Replying to boonebgorges:

32312.diff enforces this for *all* default values.

Simply applying the first part of your patch (to lines 2255-2257 of comment-template.php) fixed the issue for me.

#9 @pento
8 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 33307:

In comment_form(), ensure that filtered arguments contain all required default values.

Merge of [32511] to the 4.2 branch.

Props boonebgorges.
Fixes #32312.

Note: See TracTickets for help on using tickets.