Make WordPress Core

Opened 11 years ago

Closed 11 years ago

#32312 closed defect (bug) (fixed)

Post Comment button disappeared in some themes

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

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 11 years ago.

Download all attachments as: .zip

Change History (10)

#1 @SergeyBiryukov
11 years ago

  • Description modified (diff)
  • Summary Comment button disappeared in some themes → Post Comment button disappeared in some themes

@boonebgorges
11 years ago

#2 follow-ups: @boonebgorges
11 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
11 years ago

  • Owner set to SergeyBiryukov
  • Status new → assigned

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

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

#5 in reply to: ↑ 2 @SergeyBiryukov
11 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
11 years ago

  • Resolution → fixed
  • Status assigned → closed

In 32511:

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

props boonebgorges.
fixes #32312 for trunk.

#7 @SergeyBiryukov
11 years ago

  • Keywords commit fixed-major added; 2nd-opinion removed
  • Resolution fixed
  • Status closed → reopened

#8 in reply to: ↑ 2 @jonna
11 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
11 years ago

  • Resolution → fixed
  • Status reopened → 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.